How to add a Web reference with Visual Studio 2010

You can add a Web reference, by following the next steps:

1. 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

2. In the the URL box, enter the URL of the Web service to use, or use the links in the browse pane to locate the Web service you want. If you are developing a Web application on a machine that is behind a firewall and the application will consume Web services from outside the firewall, you have to include the address and port of your network’s proxy server in the URL.

3. In the Web services found at this URL box, select the Web service to use.

4. 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.

5. In the Web reference name field, you should 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.

6. 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.