[英]NetDispatcherFaultException error when returning escaped xml
I have a soap web service where the response body contains some escaped xml.我有一个 soap web 服务,其中响应正文包含一些转义的 xml。 So in the body of the response I have:所以在回复的正文中,我有:
<soap:Body>
<GetServiceResponse xmlns="http://www.abc.com/x/">
<GetServiceResult>
<Result>
<Value>&lt;/param&gt; etc....</Value>
</Result>
</GetServiceResult>
</GetServiceResponse>
</soap:Body>
On my client I get an exception NetDispatcherFaultException "formatter threw an exception while trying to deserialize".在我的客户端上,我收到异常 NetDispatcherFaultException “格式化程序在尝试反序列化时抛出异常”。 I am using on the client the following code:我在客户端上使用以下代码:
var binding = new BasicHttpBinding();
var address = new EndpointAddress("http://localhost:2948/ReportingService.asmx");
ReportingServiceSoap service = new ReportingServiceSoapClient(binding, address);
var response = service.GetConfig(request); <-- Exception raised on call
If I replace the escaped text with some string value (no escaped xml) then the client does not raise the exception.如果我用一些字符串值(没有转义的 xml)替换转义文本,那么客户端不会引发异常。
Any ideas where to look?任何想法在哪里看?
JD京东
With Exceptions turned on I found it was a ReadQuotas issue.打开异常后,我发现这是一个 ReadQuotas 问题。 In addition, I was testing the client interface from mSpec which meant the app.config was not being read with the corrected ReadQuotas values.此外,我正在测试 mSpec 的客户端界面,这意味着 app.config 没有被正确的 ReadQuotas 值读取。 So in code I have:所以在代码中我有:
var binding = new BasicHttpBinding();
binding.ReaderQuotas.MaxStringContentLength = 2147483647;
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReaderQuotas.MaxDepth = 2147483647;
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
This resolved the issue.这解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.