简体   繁体   English

WCF(de)序列化在debug / Visual Studio和IIS下的行为不同

[英]WCF (de) serialization behaving differently under debug/Visual Studio and IIS

I have a WCF service I am hosting, where one of the methods has an element of type xs:AnyType. 我有一个托管的WCF服务,其中一种方法的元素类型为xs:AnyType。 In my code, I serialize the xs:Any as XmlNode 在我的代码中,我将xs:Any序列化为XmlNode

In visual studio (iis express) my messages come through perfectly, with the XML loaded into the XmlNode property. 在Visual Studio(iis express)中,我的消息可以完美地传递,并且XML加载到XmlNode属性中。 When I deploy to IIS and send THE EXACT SAME MESSAGE, I get a < as the entire content of the property. 当我部署到IIS并发送“完全相同的消息”时,该属性的全部内容都得到一个<。

There is a related issue I ran into previously, where under Visual Studio the real type of the hydrated property is XmlElement, but in IIS it is coming through as XmlText (which I why I chose XmlNode, a common ancestor) See that previous issue here WCF message with xs:anytype causing serialization problems 我之前遇到过一个相关的问题,在Visual Studio中,水合属性的真实类型是XmlElement,但是在IIS中,它作为XmlText出现(我为什么选择XmlNode,它是一个共同的祖先)。 具有xs:anytype的WCF消息导致序列化问题

It seems likely that these two issues are related, but why is the application using different serialization logic under visual studio than in IIS? 这两个问题似乎可能是相关的,但是为什么应用程序在Visual Studio中使用的序列化逻辑与IIS中使用的逻辑不同?

After burning an MSDN support ticket we have found the root cause of both issues. 刻录完MSDN支持票证后,我们发现了这两个问题的根本原因。 It was not IIS vs IIS express related, the content of the messages was subtly different. IIS与IIS Express没有关系,消息的内容略有不同。

The xsd:anyType allows for arbitrary XML to be sent. xsd:anyType允许发送任意XML。 In this case, the Java application is sending HtmlEncoded xml as the payload for that element. 在这种情况下,Java应用程序将发送HtmlEncoded xml作为该元素的有效负载。 rather than puking on this content and throwing a serialization error, WCF accepts it, and hydrates it as XmlText instead of XmlElement. WCF不会接受此内容并引发序列化错误,而是接受它并将其水化为XmlText而不是XmlElement。 However, after hydration, the full payload is not there, only a < 但是,水合后,就没有完整的有效负载,只有<

Making this issue confusing is that all debug windows, the WCF traces, etc all "fixed" the htmlEncoded content to display as valid XML. 使这个问题令人困惑的是,所有调试窗口,WCF跟踪等都“固定”了htmlEncoded内容以显示为有效XML。 Therefore, when I copied the message out of the WCF Trace, and ran it manually from SoapUI to try and reproduce, the behavior changed! 因此,当我从WCF跟踪复制消息,并从SoapUI手动运行该消息以尝试重现时,行为发生了变化!

I'm pushing back on the customer to fix the payload in the message they send, but if that is not possible, using a IDispatchMessageInspector.AfterReceiveRequest method will be able to convert the payload and send it through correctly. 我正在敦促客户修复他们发送的消息中的有效负载,但是如果不可能,则可以使用IDispatchMessageInspector.AfterReceiveRequest方法将有效负载转换为正确的负载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NHibernate会话/事务在IIS6和Visual Studio 2008调试服务器上的行为不同 - NHibernate sessions/transactions acting differently on IIS6 and Visual Studio 2008 Debug Server 无法再在Visual Studio Express下调试 - Cannot debug under Visual Studio Express anymore 代码在发布与调试模式下的行为方式不同 - Code is behaving differently in Release vs Debug Mode 为什么在Visual Studio外部运行时,我的剪贴板操作应用程序的行为会有所不同? - Why is my clipboard-manipulating application behaving differently when run outside of Visual Studio? Visual Studio 2012 + IIS 8.0 =如何在本地主机上部署WCF服务? - Visual Studio 2012 + IIS 8.0 = how to deploy WCF service on localhost? 将带有WCF库的Web应用程序从Visual Studio开发人员移至IIS - Move web application with WCF library from Visual Studio dev to IIS 在 IIS 上使用 Visual Studio 远程调试器调试 program.cs - debug program.cs using visual studio remote debugger on IIS 无法在Visual Studio 2017社区版本中运行WCF调试模式 - Could not run WCF debug mode in visual studio 2017 community version Visual Studio 2010调试模式下的ArcObjects 10.2错误 - ArcObjects 10.2 Error Under Debug Mode of Visual Studio 2010 Visual Studio 2013-配置选项下缺少调试选项 - Visual Studio 2013 - Debug options missing under configuration options
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM