读取WCF消息正文两次-“无法读取消息"

问题描述:

我有一个WCF消息(Channels.Message),我正在尝试使用.GetBody()提取正文.但是,我注意到我只能执行一次,并且如果我再次尝试使用"GetBody<>",我将得到:此消息无法支持该操作,因为它已被读取."

I have a WCF Message (Channels.Message) which i'm trying to extract the body using .GetBody(). however, i notice that i can do it only once, and if i'm trying to use "GetBody<>" again, i'm getting :"This message cannot support the operation because it has been read."

有什么主意我该如何重新阅读邮件正文?

Any idea how can i re-read the message body?

谢谢

这是一篇关于您要在MSDN上尝试做的很好的文章.请参阅标题为将消息复制到缓冲区中的部分.它明确地讨论了必须多次访问消息正文.

Here is a pretty good article about what you are trying to do on MSDN. Please see the section titled Copying a Message into a Buffer. It explicitly talks about having to access the message body more than once.

http://msdn.microsoft.com/en-us/library/ms734675.aspx