开发者

Hooking into the Transport layer of WCF

开发者 https://www.devze.com 2022-12-11 02:00 出处:网络
I want to prepend the following text to the response body of a WCF operation: <?xml version=\"1.0\" encoding=\"UTF-8\"?>

I want to prepend the following text to the response body of a WCF operation:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="transform.xslt" type="text/xsl" ?>

Problem is that the Message class uses XML Readers and Writers to specify the contents of the message. Inserting this text as the first line after the tag makes the Message not well formatted.

So where does the Message object get read and the body contents written to the HTTP response stream? That i开发者_C百科s where I want to insert the two lines above.


It's called Interception, and you can define your own custom interceptions. Take a look at the following links with explanations and samples: http://msdn.microsoft.com/en-us/library/ms751495.aspx http://blogs.msdn.com/drnick/archive/2007/03/07/message-flow-interception-points.aspx


What I needed was a custom MessageEncoder.

0

精彩评论

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