Jason94
Jason94

Reputation: 13610

How to make a SOAP/WSDL client in C#?

I have been playing around in PHP with it and got something to work, what i did was:

$client = new SoapClient("http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl");
$fetchedArr = $client->GetCityForecastByZIP(array("ZIP" => "10451")); //get the weather in the bronx YO!

And now i would like my application i WPF/C# to do the same. What is the equivalent in c#?

Upvotes: 16

Views: 64899

Answers (5)

Eric Boumendil
Eric Boumendil

Reputation: 2388

If your preferred approach is to control the generated code, it's best to use the more recent SvcUtil.exe in place of Wsdl.exe.

See also WCF proxy generation: svcutil.exe vs wsdl.exe

Upvotes: 5

Amrit
Amrit

Reputation: 41

Adding web service reference to your project n making a call to the service exposed methods is your best bet . It does the trick n you're out of the hassle of creating SOAPs manually

Upvotes: 4

alimbada
alimbada

Reputation: 1401

You can use the WSDL tool to generate a C# file which will contain the necessary types and members to talk to the web service or you could add a Web Service reference. See here for more details.

Upvotes: 9

Chuvke
Chuvke

Reputation:

You can use the "wsdl.exe" command from the .NET SDK to generate the wrapper classes if you don't want or like to use Visual Studio.

see: http://msdn.microsoft.com/en-us/library/7h3ystb6%28VS.80%29.aspx

Upvotes: 2

thelost
thelost

Reputation: 6694

The simplest way is to use VS and add a web reference. This automatically creates the stub for you

Upvotes: 27

Related Questions