1

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

Community
  • 1
  • 1
GPGVM
  • 5,515
  • 10
  • 56
  • 97
  • I'm not sure that I understand without some hand holding. I am doing the following. My client has a service reference with the domain of say WCFDomain. My request is as you might expect a class of the WCFDomain. Same for my Response. So I create my request and response objects and populate the request. Then I call the service sending the request object and the results are returned to my response object. The object is as I wanted as far as data goes but really I just want the XML / deserialized version. – GPGVM Dec 28 '12 at 11:36

1 Answers1

1

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.

Jens H
  • 4,590
  • 2
  • 25
  • 35
  • Well you know I started down that road but a post from another person responding to my question said I didn't understand how WCF services work. Honestly I think I didn't ask the question well and thus the answer. Anyway this makes sense. Thank You – GPGVM Dec 28 '12 at 11:50