Managing Project Web References
Web references differ from traditional references and components in that they refer to XML Web services published on either a local intranet or the Internet. The standard references that programmers are accustomed to adding to their applications are to components and class libraries installed on the local computer. You add a Web reference to your project when you want to incorporate functionality from a Web service into your application. For instructions on creating a Web reference, see Adding and Removing Web References.
You manage project Web references by renaming or modifying them to suit your needs or by updating them when changes have been made to the Web service the reference calls.
Renaming a Project Web Reference
The Web reference's name is also its programmatic namespace. The namespace can be changed to suit your needs. You can change the name of the Web reference to any string expression that is meaningful to its function. For example, you could change the name of a Web reference that handles account totals to "AccountTotal."
To rename a Web reference in a project
- In Solution Explorer, expand your project's Web References folder, and then select the node for the reference you want to rename.
- On the File menu, choose Rename.
A box appears around the selected reference.
- Type the new name for the reference, and press ENTER.
Note If you have used the old name elsewhere in your project code, remember to change each occurrence to the new name.
Updating a Project Web Reference
If your application contains a Web reference to an XML Web service that has been recently modified on the server, you may need to update the reference in your project. For example, you may need to update a Web reference when new methods are added to an existing XML Web service on a server. In this case, you would need to generate a new proxy for the Web service so you can access the new method; this happens automatically when you update the Web reference.
To update a project Web reference
- In Solution Explorer, access your project's Web References folder and select the node for the Web reference you want to update.
- Right-click the reference and click Update Web Reference.
The new files for the XML Web service are downloaded to your project. Information for the XML Web service is updated within your project.
URL Behavior Property
Each Web reference in your project interacts with a proxy class that is used to access the Web service's contents. You can use the UrlBehavior property to control the way a proxy class obtains the URL for a specific Web reference. The property has two settings:
|Static||The proxy class sets the URL using a hard-coded URL when you created the instance of the class.|
|Dynamic||The application obtains the URL at run time from the <appSettings> Element element of your application's configuration file.|
For more information on dynamic versus static Web references, see Locating XML Web Services.
Adding and Removing Web References | Add Web Reference Dialog Box | Web Access Methods | Creating Web Projects | Opening Web Projects | Changing Web Project Access Methods | Visual Basic and Visual C# Projects | Referencing Namespaces and Components