Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
XML Web Services
 How to: Call a Web Service
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:

Want more? Here are some additional resources on this topic:

Visual Web Developer 
How to: Call a Web Service 

After you add a Web reference to the XML Web service to your project, you can use the server name to create a proxy object that allows you to call the methods in the XML Web service.

To call a Web service programmatically

  • Use the Web reference name (or server name) as the namespace, and the name of its .WSDL file (or the service name) as the proxy class.

    The following code example calls a Web service method to get a string value. Web service variable names and syntax are highlighted.

    Visual Basic
    Private Sub Call_Web_Service_Method() 
        Dim <b>CallWebService</b> as New <b>ServerName.WebServiceName()</b> 
        Dim <b>sGetValue</b> as String = <b>CallWebService.MethodName()</b> 
        Label1.Text = <b>sGetValue</b> 
    End Sub 

    C#
    private void Call_Web_Service_Method()
    {
        <b>ServerName.WebServiceName</b> <b>CallWebService</b> = 
            new <b>ServerName.WebServiceName()</b>;
        String <b>sGetValue</b> = <b>CallWebService.MethodName()</b>;
        Label1.Text = <b>sGetValue</b>;
    }

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
The C# Code      g-unit   |   Edit   |   Show History
C#
      private
      void Call_Web_Service_Method()
{
    ServerName.WebServiceName CallWebService = new ServerName.WebServiceName();
    String sGetValue = CallWebService.MethodName();
    Label1.Text = GetValue;
}
Tags What's this?: c# (x) call (x) service (x) web (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker