SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Matt Ward

Web References

To consume or call a web service from your application you can add a web reference to your project.Once the web reference has been added to your project the web service will be available to you as a web service proxy class, which you can create and execute any of its methods. Executing a method on this class will call the corresponding web service method and return the result. If the web service changes you can refresh the web reference which recreates the web service proxy class.

You can only add web references to C# and VB.NET projects.

Adding a Web Reference

  1. With a project open in SharpDevelop, open the View menu and select Projects... to open the Projects Explorer.

  2. In the Projects Explorer, right click the project and select Add Web Reference .

    This opens the Add Web Reference dialog

    .

  3. Type in a URL and browse for a web service by pressing the return key or by clicking the Go button . The screenshot below shows the Add Web Reference dialog after the URL http://localhost/Maths.asmx has been typed in and the web service on the local machine has been found and displayed.

  4. Change the name of the web reference by changing the text in the Reference Name text box. The default value is set to the web service host name, which in the screenshot above is localhost.
  5. Change the namespace to be used for the web proxy class by changing the text in the Namespace text box. The default value is set to the root namespace of the project followed by the web service host name.
  6. Click the Add button to add the web reference to your project. SharpDevelop will then create the web reference and display it in the Project Explorer. Expanding the web reference in the Project Explorer you can see the files that SharpDevelop has generated.

    Now you can use the web service proxy class in your application.

Refreshing a Web Reference

If the web service changes you can recreate the web service proxy class to reflect any new methods or new parameters by refreshing the web reference.

  1. Open the View menu and select Projects... to open the Projects Explorer.

  2. Expand the Web References.
  3. Select the name of the web reference you want to refresh, right click and select Refresh Web Reference .

    The web service proxy will then be regenerated to reflect the changes made to the web service and you can update your code.

Removing a Web Reference

  1. open the View menu and select Projects... to open the Projects Explorer.

  2. Expand the Web References.
  3. Select the name of the web reference you want to remove, right click and select Delete .

    If your application has several web references you can delete all of them in one step by selecting Web References in the Project Explorer, right clicking and selecting Delete.

Published Jun 27 2006, 04:56 PM by MattWard
Filed under:

Comments

No Comments
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.