我使用Soap Client 调用接口的时候,一个接口返回的结果过长,引起了错误,调用代码如下
报错信息如下
网上找到的解决方案都是.net配置server.config的解决方案和java的不匹配。
我使用Soap Client 调用接口的时候,一个接口返回的结果过长,引起了错误,调用代码如下
报错信息如下
网上找到的解决方案都是.net配置server.config的解决方案和java的不匹配。
如果你使用的是ASP.NET WebService,可以在web.config文件中添加以下配置:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="5000000"/>
</webServices>
</scripting>
</system.web.extensions>
其中maxJsonLength属性的值可以根据需要进行调整。
如果你使用的是WCF服务,可以在服务配置文件中添加以下配置:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="5000000"/>
</webServices>
</scripting>
</system.web.extensions>
如果你使用的是Soap Client调用接口,可以在调用方法前添加以下代码:
System.ServiceModel.Channels.Binding binding = client.Endpoint.Binding;
System.Xml.XmlDictionaryReaderQuotas quotas = new System.Xml.XmlDictionaryReaderQuotas();
quotas.MaxArrayLength = int.MaxValue;
quotas.MaxStringContentLength = int.MaxValue;
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, quotas, null);
其中MaxArrayLength和MaxStringContentLength属性的值可以根据需要进行调整。