Discover how to create a Microsoft Windows application that uses web service operations.
Setup Tasks
This lab is dependent on the previous two labs. Simply downloading the
completed code files from the previous labs and installing them on your IIS Server may not work due to
IIS Server settings. To set up a web service project and define web service operations and attributes,
see the lab entitled Define and implement the web service operations and attributes
for more details. To compile, test and publish the web service see the lab entitled
Compile, test and publish the web service.
Tasks
The complete sample code is available at the end of this section.
In Microsoft Visual Studio .NET, on the File menu, click New > Project.
In the Project Types tree, click the Visual C# Projects folder.
In the Templates pane, click Windows Application.
Change the project location to a local directory, for example, c:\temp\MetricConvWSTest
Click OK.
To create a web reference to the Measurement Conversion web service, in the Solution Explorer window, right-click the References tag.
Click Add Web Reference.
Type the path to the metric conversion web service at http://localhost/MetricConvWS/Service1.asmx.
Click Go.
When the web service is detected, click Add Reference.
To add a button to test the web service, in the Toolbox pane, drag the Button control to the application form.
Double-click the button.
Add the following code to the button1_Click method: