Add a web reference to the application

We are now at the stage where we need to enlist the help of the web application developer, and use Visual Web Developer (VWD) or Visual Studio (VS). I assume that you are the web developer, so here is what you need to do first.

Before you can call a web service from an ASP.NET application you must add a reference to that web service into your site. I will assume you have closed your web site in the web page editor and you are ready to proceed.

Solution explorer view of a typical small websiteStep 1: Open your website in VWD or VS

The File|Open Website allows you to open your website folder as an active ASP.NET website. Make sure you open the folder containing your website, and not just the folder with your web page, as this will make configuration and expansion easier further on in the development process. In Solution Explorer you should see the structure of your site will files and folders, as well as the main folder for the site.

Add Web Reference dialogStep 2: Add a Web Reference

Right click the website folder (highlighted in the image above) and choose Add Web Reference …. In the dialog type the URL of the web service you want to use and click Go.

Chosen Web ReferenceThe web service reference page should load into the browser area to confirm that you have selected the correct service. Now change the Web reference name to something more appropriate (in the case of the Global Weather web service I have chosen to use MyWeather. This name is used when we come to code the service so it is important we use something simple, concise and relevant. Now click Add Reference.

Web reference listed in the solutionThe web reference should appear in the solution explorer in confirmation of your actions.

We are now ready to add the code to make our web service do its job.

Valid XHTML 1.0! | Valid CSS! | WCAG Approved AA
Page design by: John P Scott - Hosting with: Netcetera