连接到 WCF 的传输层
我想将以下文本添加到 WCF 操作的响应正文中:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="transform.xslt" type="text/xsl" ?>
问题是 Message 类使用 XML Readers 和 Writers 来指定消息的内容。将此文本作为标记后的第一行插入会使消息格式不正确。
那么从哪里读取 Message 对象并将正文内容写入 HTTP 响应流呢?这就是我想插入上面两行的地方。
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 is where I want to insert the two lines above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这称为拦截,您可以定义自己的自定义拦截。请查看以下包含说明和示例的链接:
http://msdn.microsoft.com/ en-us/library/ms751495.aspx
http://blogs.msdn.com/drnick/archive/2007/03 /07/message-flow-interception-points.aspx
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
我需要的是一个自定义的 MessageEncoder。
What I needed was a custom MessageEncoder.