添加 WCF 服务引用回退到 XmlSerializer
我们通过向项目添加 WCF“服务引用”来使用 ASMX 服务。当我们这样做时,默认情况下应该使用DataContractSerializer
,如果出现问题,它将回退到XmlSerializer
。
我尝试在生成代理类时强制使用 DataContractSerializer
,但是当我这样做时,它们是不完整的并且缺少 Web 服务使用的所有自定义类(仅留下用于Soap、SoapChannel 和 SoapClient 类)。
好吧,出了点问题,它又转而使用 XmlSerializer
。生成参考时,我没有看到任何错误或警告。
如何找出导致 DataContractSerializer
失败并回退到 XmlSerializer
的原因?
We are consuming an ASMX service by adding a WCF "Service Reference" to our project. When we do this, by default it is supposed to use the DataContractSerializer
and if something goes wrong, it will fall back to the XmlSerializer
.
I've tried forcing the DataContractSerializer
when generating the proxy classes, but when I do that, they are incomplete and missing all of the custom classes used by the webservice (leaving only the interface for the Soap, SoapChannel, and the SoapClient class).
Well, something is going wrong and it is falling back to the use the XmlSerializer
. I do not see any errors or warnings when I generate the reference.
How can I find out what is causing the DataContractSerializer
to fail and fall back to the XmlSerializer
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
长话短说,我们无法强制 VS 使用 DataContractSerializer。相反,我们最终编写了自己的代表 Web 服务的 WCF 服务契约。当我们使用服务时,我们通常使用我们自己的服务合约来创建 ChannelFactory。下面是我们用来创建通道的代码。
Long story short is that we were unable to force VS to use the DataContractSerializer. Instead we ended up writing our own WCF Service Contracts that represented the webservice. When we consume the service we are instead creating the ChannelFactory generically by using our OWN Service Contracts. Below is the code that we used to create the channel.