There are several things you can do to create this code. The first and easiest way (in my opinion) is to create a link to this URL. Here are some screenshots:
Right click on your project, add a link to the service:

Put the url for asmx (no method in querystring), give the link a name and click OK:

This will create the proxy code needed to make the call:

From there, you can simply use this proxy code to call the web service:
TerraService.TerraServiceSoapClient client = new TerraService .TerraServiceSoapClient("TerraServiceSoap"); string place = client.ConvertLonLatPtToNearestPlace( new TerraService.LonLatPt { Lat = 47.6532, Lon = -122.135479 });
The second method is to use the WSDL.exe command-line WSDL.exe that comes with visual studio. Run the visual studio command line and enter wsdl /? . This will show you the options for the application. In my case, I just took a copy of WSDL from http://msrmaps.com/terraservice2.asmx?wsdl , saved it on my desktop, and ran the command:
wsdl /o:./terraservice.cs terraservice.wsdl
Creates a proxy class next to my WSDL file.
One last thing ... to become best friends with soapUI, as Habibilla suggested. This is a fantastic tool to call web services without having to write code.
Hope this helps!
source share