返回转义xml时出现NetDispatcherFaultException错误
本文关键字:NetDispatcherFaultException 错误 转义 xml 返回 | 更新日期: 2023-09-27 18:00:37
我有一个soapweb服务,其中的响应主体包含一些转义的xml。因此,在我的回复中:
<soap:Body>
<GetServiceResponse xmlns="http://www.abc.com/x/">
<GetServiceResult>
<Result>
<Value>&lt;/param&gt; etc....</Value>
</Result>
</GetServiceResult>
</GetServiceResponse>
</soap:Body>
在我的客户端上,我得到一个异常NetDispatcherFaultException"格式化程序在尝试反序列化时抛出了一个异常"。我在客户端上使用以下代码:
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
如果我用一些字符串值(没有转义xml)替换转义文本,则客户端不会引发异常。
有什么想法吗?
JD
打开"异常"后,我发现这是ReadQuotas问题。此外,我正在从mSpec测试客户端接口,这意味着没有使用更正的ReadQuotas值读取app.config。所以在代码中我有:
var binding = new BasicHttpBinding();
binding.ReaderQuotas.MaxStringContentLength = 2147483647;
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReaderQuotas.MaxDepth = 2147483647;
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
这解决了问题。