Home » x Other Posts » How to create code for a web service client from a WSDL URL

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:

  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)

Ned Sahin

Blogger for 20 years. Former Microsoft Engineer. Author of six books. I love creating helpful content and sharing with the world. Reach me out for any questions or feedback.

Leave a Comment