问题描述
我需要检索出现在邮件正文中的标头值.我通过使用MessageHeaderInfo进行迭代,然后得到名称和名称空间.我也尝试使用GetType检索类型.当我遍历诸如To,ReplyTo等的标准消息头时,我可以将其类型视为
i need to retrieve the values of headers that appears in a message body. i am iterating by using MessageHeaderInfo and then i get the name and the namespace. I also try to retrive the type using GetType. When i iterate through standard message headers like To, ReplyTo etc, i could see thier types as
System.ServiceModel.Channel.ReplyTo等...
System.ServiceModel.Channel.ReplyTo etc ...
我的问题是对于ToHeader,ReplyHeader等标准标头,我无法检索标头值
My problem is for the standard headers like ToHeader,ReplyHeader etc, I am unable to retrive the header values
因为它们是内部类,所以不能将它们用作GetHeader的参数.
by using the GetHeader<T> as because they being internal classes, I cannot use them as an parameter to GetHeader.
有人可以建议一些替代方法来检索标头内容吗?
Could someone suggest some alternate ways of retreiving the header contents?
进一步,使用字符串"对内容进行反序列化.作为类型会产生序列化异常错误,如下所示;
Further, desrializing the content using "string" as a type produces as Serialization exception error as follows ;
反序列化类型为System.String的对象时发生错误.预期来自名称空间"http://www.w3.org/2005/08/addressing"的元素"ReplyTo".从名称空间"http://www.w3.org/2005/08/addressing"找到了元素"a:Address".第1行,位置257.
谢谢
推荐答案
我已经通过使用GetReaderAtHeader()暂时解决了该问题,该方法为我们提供了XMLDictionaryReader,然后通过将其移动,可以成功获取标头内容.
i have temporarily resolved the problem by using GetReaderAtHeader() which gives us an XMLDictionaryReader and then by moving thru it, i could succesfully get the header content.
但我仍然不知道为什么要传递给getheader< T>的哪种类型?
but i am still at lost as to what type to pass to why getheader<T>?
谢谢
这篇关于messageheaders getheader< T>错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!