質問

Possible Duplicate:
Get Just the Body of a WCf Message

Good Morning,

I have a WCF service that build a complex object then sends it to the consuming client. Currently the service works great but the xml is reinflated / deserialized on the client and I don't want this as the client wants to work with the XML.

So is there a way to get the "XML document" that is transmitted as a part of the WCF service response. Of course I could just serialize it again on the client but really why do extra steps if they can be avoided.

TIA JB

役に立ちましたか?

解決

Although there are possiblities to hook into the multiple WCF receive/send steps on both server and client sides, where you could influence on how the serialization is executed (not not executed in your case), I believe that would be too much overhead for your scenario.

You'd be better of to simplify the workflow and stick with the out-of-the-box functionalities.

I think the easiest approach would be to manually serialize your objects only on the server side and simply send the result as a string back to the client.

To remain flexibility (you might later want to add more data accompanying the serialized data) put this serialized XML into a property of dedicated Data Transfer Object (DTO).

This DTO is then send to the client who simply reads the XML from that property.

Under the hood there still is, of course, some serialisation going on. But this would be the built-in functionality hat is totally transparently executed by the WCF service/ client communication. If you do not have a serious reason to do influence it manually, leave it as it is. If you do not know what you are doing you might instead open the box of Pandora...

Sending a simple object like the above described DTO should not be much of a deal here. I mean, this scenario would mainly be sending a bunch of strings over the wire, which should not cause any troubles and very little overhead.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top