Web 服务:反序列化回复消息正文时出错 [英] Webservices: Error in deserializing body of reply message
问题描述
使用 Visual Studio 2010,我正在调用 SOAP 网络服务并不断收到错误反序列化回复消息正文时出错".
Using Visual Studio 2010, I'm calling SOAP webservices and keep getting the error "Error in deserializing body of reply message".
我这样调用 WS 方法:
I call the WS method like this:
wsConfig.config_pttClient client = new wsConfig.config_pttClient();
wsConfig.getConfigInput gci = new wsConfig.getConfigInput();
wsConfig.getConfigOutput gco = new wsConfig.getConfigOutput();
gco = client.getConfig(gci); // the exception is thrown here
该方法不需要输入数据:我使用 SoapUI 对其进行了测试,并且运行良好.使用 fiddler,我看到呼叫已完成,所有数据的答案都是正确的.
The method doesn't need input data: I test it using SoapUI and it works fine. Using fiddler, I see the call is made and the answer with all the data correct.
经过一段时间的研究,我试图改变xsd
中的readerQuotas
,如maxStringContentLength
、maxDepth
等代码>但没有运气.
After researching for a while, I tried to alter the readerQuotas
like maxStringContentLength
, maxDepth
etc. inside the xsd
but no luck.
不过,我对 getConfig
方法有了一些解决方法:当我更改 Reference.cs
文件并更改 System.DateTime
变量时类型为 string
,它工作正常,但随后我需要调用一个 setConfig
方法,而这种改变带来了 另一个问题...此外,我已经读到更改网络服务合同不是一个好的做法.
I got a little workaround for the getConfig
method though: when I alter the Reference.cs
file and change the System.DateTime
variable types to string
, it works fine but then I need to invoke a setConfig
method, and that alteration brings another problem... Also, I've read that altering the webservice contract isn't a good practice.
我一直在寻找解决方案一段时间了,这里有一些我检查过的地方:这个,this, this 或 this.
I've been looking for a solution for a while now and here are some places I checked: this, this, this or this.
有人可以帮忙吗?谢谢
推荐答案
似乎我找到了解决问题的方法:
Seems I found a workaround for the problem:
在服务引用下的 reference.cs
文件中,我将每个 DateTime
和 System.Nullable
对象更改为string
的 - 正如我之前尝试过的 - 通过这种方式能够制作 get
方法.
in my reference.cs
file under the service reference, I changed every DateTime
and System.Nullable<System.DateTime>
object to string
ones - as I had tried before - being this way able to make the get
method.
当尝试调用 set
方法时,我通过以下方式传递日期:
When trying to call the set
method, I pass the dates with this:
vt.beginDate = DateTime.Now.ToString("o");
ToString("o")
似乎是防止序列化问题的有效解决方案.
The ToString("o")
seems to be the working solution in order to prevent serialization issues.
这篇关于Web 服务:反序列化回复消息正文时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!