Using Visual Studio to generate a web service proxy class library that does not contain web references

To generate a proxy for a web services (within Visual Studio) that is not referenced using traditional Web References. follow these steps:

  1. Right click on the Proxy project and select Add Web Reference.
  2. Enter the URI of the web service you are trying to access and click Add Reference. This will create a Web References Folder and a localhost node in the tree.
  3. Click the Show All Files icon from above in Solution Explorer. This will allow you to drill-down into the localhost reference by clicking the +.
  4. Expand both localhost and Reference.map and you will see the Reference.cs file. This is the generated proxy.
  5. Copy the code from in the Reference.cs file.
  6. Add a new class to the Proxy project and paste the code copied from Reference.cs into the new class. Ensure that the name of your newly created .cs file matches the name of the class you are pasting in.
  7. Delete the localhost node in the Web Reference folder.
  8. Delete the Web References folder.
  9. Tidy up the pasted proxy class.
    1. Correct the namespace to be the same as your proxy project’s default namespace.
    2. Add an entry into the Settings.settings file with the URI of the new service (add a Settings File to your project if you don’t currently have one).
    3. there will be one or more places there the generated code states "this.Url = global::", change this reference to this.Url = global::<ProjectName>.Settings.Default.<Entry name you created in the settings file>.

                    e.g. 

                          global::MyProject.ServicesProxy.Settings.Default.ClaimService

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s