开发者

Passing XML document to a web service using WCF

开发者 https://www.devze.com 2023-01-05 22:41 出处:网络
I need to pass an XML document to the web service. Is it possible to simply specify a contract with a method, say

I need to pass an XML document to the web service. Is it possible to simply specify a contract with a method, say

void Method(XmlDocument myDocument);

and implement it in a standard way? I need to keep in my the Silverlight functionality, thus I want to avoid writing the XML to a stream... Is it a good approach?

Thank you in advance for the开发者_Python百科 hints and replies!

Cheers


If i recall correctly, XmlDocument is not serializable (which is required for a webservice).

The easiest way would be to write the xml document to a string ( xml), send this to your webservice and there you can deserialize it again to an XmlDocument


I've personally done this (forced too...). WCF has string buffer and string deserialization limits in the WCF binding which you need to override if you are sending anything of size through the interface.

But that said, if your requirement is to simply send XML then create a class, decorate it with the WCF XML attributes and then declare your interface to send them.

If you are interoperating with an existing service, you should be able to use the WCF service tools in the windows SDK to create a WCF binding against the service for you.


If you must pass in that XML document, pass it as a string. But the whole point of the WCF services is that you don't have to fiddle around with XML yourself - you just call the method and pass it some parameters (ints, strings, your own types) and the WCF runtime handles all the thorny XML stuff for you....

0

精彩评论

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