开发者

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 i开发者_高级运维n C++.

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


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.


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).


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".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜