pixelchain blogs

Friday, January 07, 2005


Accessing WebServices in C# 

Create Web Service Proxy from WSDL file

Start the command prompt in the folder where your C# project files resides:

wsld.exe http://WebServiceDomain:Port/WebservicePath/WSDLPath

The C# Proxy is generated

Add the Proxy C# file to the project

Instantiate the SOAP Interface

IMyClass MyClass = new IMyClass();

Call the Service method(s)

IMyClass.MyMethod(MyParam1,...)

An example:

http://www.webservicex.net/geoipservice.asmx/GetGeoIP?IPAddress=212.227.119.102

will return the country where my web site is hosted.

The WSDL file is located here:

http://www.webservicex.net/geoipservice.asmx?WSDL

Create the Proxy: wsdl http://www.webservicex.net/geoipservice.asmx?WSDL.

As a result the GeoIPService.cs is generated. You can add it to your current C# project.

In order to instantiate the GeoIPService interface and retrieve the geographical IP Information type the following code:

GeoIPService GeoIPLookUp = new GeoIPService();
GeoIP IPInfo = new GeoIP();
IPInfo = GeoIPLookUp.GetGeoIP("212.227.119.102");
this.Text = IPInfo.CountryName+" ["+IPInfo.CountryCode+"]";

 

Links
home »
pixelchain »

Archives
09/01/2003 - 09/30/2003 » 10/01/2003 - 10/31/2003 » 12/01/2003 - 12/31/2003 » 01/01/2004 - 01/31/2004 » 03/01/2004 - 03/31/2004 » 09/01/2004 - 09/30/2004 » 01/01/2005 - 01/31/2005 »