开发者

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

开发者 https://www.devze.com 2022-12-29 11:27 出处:网络
I have been playing around in PHP with it and got something to work, what i did was: $client = new SoapClient(\"h开发者_如何学运维ttp://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl\");

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

$client = new SoapClient("h开发者_如何学运维ttp://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#?


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


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.


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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号