tags:

views:

19

answers:

2

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?

+1  A: 

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.

Darin Dimitrov
+1  A: 

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.

cHao
Do you have an example of using the proxy classes?
joek1975
I could provide one, but it would look quite the same as if i were using local objects (which is part of my point). It wouldn't be helpful without the solution file including the reference and the proxy classes themselves, which can be a *lot* of code depending on the service being referenced.
cHao