Skip to main content

How to create code for a web service client from a WSDL URL

Wouldn’t be nice to have a tool to create web service client code automatically? Web services already provide WSDL files to provide guidance about their offerings. We just need a tool to understand these files automatically and create all the code we need to consume them.

The tool we have been looking for is WSDL to Proxy Class Tool. It generates proxy code to be used as a web service client based on the WSDL file you provide.

How to create web service client code?

Here are the high level steps about creating code for web service clients by using WSDL to Proxy Class Tool:

The Most Functional and Compact Toiletry Bag
  1. Open “Developer Command Prompt for Visual Studio” as Administrator
  2. Go to root of C: drive by typing cd\
  3. Run this command: wsdl.exe WSDL-path-or-url
  4. Go to C: drive and copy the source code to your solution file
  5. Call the method you want to use in your application. For example: I used the code block below to call a sample method (getBank):
static void Main(string[] args)
{
   Console.WriteLine("Result:");
   BLZService blz = new BLZService();
   detailsType result = blz.getBank("48080020");
   Console.WriteLine(result.bezeichnung.ToString());
   Console.Read();
}

Here is a sample WSDL URLs to use for testing: Weather Web Service. More here. Also, you may want to check a related StackOverflow topic and a sample application.

After implementing the code, are you receiving 503 error when you try to access your application? Check this out: HTTP 503 Service Unavailable (Application pool has been disabled)

The Most Functional and Compact Toiletry Bag

Leave a Reply

Your email address will not be published. Required fields are marked *