code4life
code4life

Reputation: 15794

Best way to generate a soap xml message?

What is the best way to generate soap xml in c#? I prefer to use xml-serialization if possible. Also, I need to add some custom attributes to the soap header, so not sure if this complicates things.

One more note: I'm connecting to a soap server on a linux server over TCP - the soap server was built in C++.

Also, the soap server does not respond to wsdl requests - it's fully locked down. Security is extremely tight where I work... :)

Upvotes: 3

Views: 4533

Answers (3)

Paul Turner
Paul Turner

Reputation: 39685

If you have an XSD, take a look at WSCF.blue.

This article should introduce the concept behind it. You may need to generate some of the service definition yourself, but it should make building WCF contracts and a client proxy a lot easier than coding the SOAP messages by hand.

Upvotes: 2

John Saunders
John Saunders

Reputation: 161831

The best way would be to use "Add Service Reference" and point to the WSDL of the service, either on disk or on the net. Then call the service through the generated proxy class.

See "How to Consume a Web Service".

Upvotes: 0

marc_s
marc_s

Reputation: 755321

What are you trying to do? Call a webservice??

Use WCF and "Add Service Reference" in Visual Studio - and you're done!

No need to painstakingly, manually construct any SOAP messages - let WCF handle all the gooey stuff for you and concentrate on your actual business!

See msdn.microsoft.com/WCF for a great intro site and lots of article and videos and stuff.

And yes - using WCF does allow you to use XML serialization if you insist - but the native WCF DataContractSerializer might be an even better choice (approx. 10% faster than XML serialization, in most cases).

Upvotes: 0

Related Questions