开发者

inject into before serialization wcf

I want to use IDispatchMessageInspector and BeforeSendReply method to change replay before return to client but it is too late cause message are serialized then.

It is another wcf inter开发者_开发技巧face or other way to change data returned by service but not serialized yet?

I want to use data return by service to generate new data and do my own serialization when accept type is text/html


The component which converts between the return object and the outgoing message is the IDispatchMessageFormatter. Content negotiation (changing the response format depending on the incoming Accept header) is doable in the "classic" WCF, but you'll need to write your own formatter to deal with it - on incoming requests it would check what's the accept header and store it somewhere (such as the operation context), and on outgoing responses it would get the value of that header and decide how to format the outgoing response.

With the WCF Web APIs, however, content negotiation is a lot easier, and there are indeed many samples that do exactly that. Check it out at http://wcf.codeplex.com - the Content Manager sample has some content negotiation capabilities.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜