Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return already serialzed type in WCF

I'd like to use WCF to set up a cross-plattform WebService. A problem - actually more a performance issue - is that I'd like to return a Type (let's say Event) and I have this event already in XML. So I'd like to avoid deserializing to Event and then WCF is serializing it back to XML. Any idea how to manage this? What I want to achieve is something like "WCF, this method returns an Event-object but I've already serilized it to XML so take it and don't force me to deserialize it first so you can serialize it again".

Daniel

like image 324
GeneralOfTheFelixLegions Avatar asked Nov 05 '22 21:11

GeneralOfTheFelixLegions


1 Answers

The WCF component that does message (de)serialization is the MessageFormatter.

Hence, you could provide a custom IDispatchMessageFormatter. In the SeralizeReply() method (which returns a Message) you could use the Message.CreateMessage() overload that takes an XmlReader and supply an XmlReader that you create from your XML. And that's it. A bit of work to do, though. You need to decide whether it's worth it.

like image 198
mthierba Avatar answered Nov 09 '22 14:11

mthierba