|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
How to: Add and Remove Web References
A Web reference enables a project to consume one or more XML Web services. Use theto search for Web services locally, on a local area network, or on the Internet.
After adding a Web reference to your current project, you can call any methods exposed by the Web service. For details, see.
For information about creating a Web service class, see.
To add a Web reference to a project
In Solution Explorer, right-click the name of the project to add the Web service to and then click Add Web Reference.
The Add Web Reference dialog box is displayed.
In the URL box, enter the URL of the Web service to use. If you do not know the URL, use the links in the browse pane to locate the Web service you want.
If you are developing a Web application on a computer that is behind a firewall, and your application will consume Web services from outside the firewall, you must include the address and port of your network's proxy server in the URL. Ask your network administrator to furnish this part of the URL path. For more information, see "The proxy settings on this computer are not configured correctly for Web discovery" in the Visual Studio 2005 SDK.
In the Web services found at this URL box, select the Web service to use.
Verify that your project can use the Web service, and that any external code provided is trustworthy.
When you open a project for editing that includes a Web reference, a local proxy file for the Web service consumed runs in a process of Devenv.exe started by a trusted user, yourself. Opening projects or components in the integrated development environment (IDE) can execute code on your local computer. For more information, seeand .
In the Web reference name field, enter a name that you will use in your code to access the selected Web service programmatically.
By default, Web references are assigned a namespace that corresponds to their server name. You can change this value and enter a custom namespace name. There are some limitations on acceptable namespace names. For more information about characters that are not allowed in a Web reference name, see. Visual Web Developer creates a namespace based on the Web reference name by building a nested folder hierarchy. Inside the innermost folder, a .wsdl file that references the Web service is created, along with supporting files, such as discovery (.disco and .discomap) files, that include information about where the Web service is located.
Click Add Reference.
If your Web site does not already have one, Visual Studio creates an App_WebReferences folder. It then creates files required for the proxy class using the name you provided in Step 5.
Removing a Web Reference
If your project no longer needs a Web reference to an XML Web service, you can remove the reference from your project.
To remove a Web reference from a project
In Solution Explorer, right-click the Web reference and then click Delete.
All the reference information is removed from the project and from local storage.