[英]Copy the RequestMessage at IParameterInspector.BeforeCall() on WCF Service
I have WCF service with IParameterInspector
class which suppose to store the message for each incoming message. 我有带有
IParameterInspector
类的WCF服务,该服务IParameterInspector
为每个传入消息存储消息。 I need to extract values from the inputs parameters. 我需要从输入参数中提取值。
In order to get the message I'm trying to access 为了获取消息,我正在尝试访问
Blockquote OperationContext.Current.RequestContext.RequestMessage Blockquote
块引用OperationContext.Current.RequestContext.RequestMessage块引用
and than call to CreateBufferedCopy()
method to create a copy so I can work (read) the message and send it forward, but than I'm getting the following error: 然后调用
CreateBufferedCopy()
方法创建一个副本,这样我就可以处理(读取)消息并将其转发,但是却出现以下错误:
"This message cannot support the operation because it has been read." “此消息无法支持该操作,因为已读取该消息。”
Any ideas? 有任何想法吗? Many thanks!
非常感谢!
IParameterInspector
is fired after the message has been read by the data contract/xml serializer so the message body has been already consumed. 数据协定/ xml序列化程序已读取消息后,将触发
IParameterInspector
因此消息主体已被使用。
If you want to get the raw input message, you should be doing so in an IDispatchMessageInspector
instead and make a buffered copy of the message so that you can still pass it on further down the WCF pipeline. 如果要获取原始输入消息,则应改为在
IDispatchMessageInspector
进行此操作,并对该消息进行缓冲复制 ,以便仍可以将其沿WCF管道进一步传递。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.