This course - Write a client application that calls the internet web service (Tutorial 3)

v1.0 - last updated: 08/07/2006

In this tutorial, you write a Windows client application that calls the internet web service from Tutorial 2.  There are 7 steps...
 


  1. In the same solution, create a Windows application project.
    Select the solution name and right-click.  In the popup menu, select Add...New Project...



  2. In the Add New Project popup, select Visual C#, Windows Application, and a name of HelloClient.  You may also choose to modify the location:


    You'll now get a new project in your solution, as follows:

     
  3. Make the Windows application the default project in the solution.
    Right-click on the HelloClient project, and in the popup menu, select Set as Startup Project.


  4. You should now see the HelloClient project highlighted:

     
  5. Add a Web Reference to the client project.
    Select References and right-click; in the popup menu, select Add Web Reference:


    Enter the internet server's URL from Tutorial 2 in the URL textbox:


    Click on Go and you should see the HTML version of the service's WSDL page below the URL:


    Click the Add Reference button in the lower right of the Add Web Reference popup (above).  The project should now display a web reference something like the one shown below:

     
  6. Add a button and textbox to Form1.
    Open Form1 in Design mode, open the Toolbox, and add a button and a textbox to the form:

  7.  
  8. Add three lines of code in Form1 to instantiate and call the web service.
    Open Form1's code view; it will look like this:

    Add three lines of code--line 16, 19 and 23 (you can copy and paste from here) to Form1:


  9.  
  10. Build the HelloClient() project.

  11.  
  12. Run it.
    If successful, you should be able to click the button and see the value returned by the web service as follows:

This is the end of Tutorial 3.  See other tutorials.



Visitors: Hit Counter