开发者

How do I send/Receive SOAP messages usiung .NET

开发者 https://www.devze.com 2023-01-12 20:06 出处:网络
I am new to SOAP. I have to send XML using SOAP to an external web service on the internet and parse the response.

I am new to SOAP. I have to send XML using SOAP to an external web service on the internet and parse the response.

How can I do this using the .开发者_高级运维NET Framework 3.5?


You could take a look at WCF. You can generate a proxy class using svcutil.exe in order to invoke the remote web service. Here's a tutorial you may take a look at about consuming web services in .NET.


Basically, you can create a "web reference" (or "service reference", depending on how the server did things) to the remote service, then use the proxy classes created by VS to work with the the service more-or-less as if it were a local object. The proxy classes handle all the SOAP details for you.

With the web reference set up, you could say something like this, assuming we created a reference called "ReferenceName" to a server offering a GreetingService that'd give us a greeting in a million different languages:

var svc = new ReferenceName.GreetingService();
string greeting = svc.GetGreeting("en-us");
// greeting could be "Hello!" here, depending on the service author's sense of flair.

I haven't gotten into error handling, in order to keep this simple. But it'd work about the same as it would for local objects, except you'll get different exceptions.

0

精彩评论

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