我用以下代码连接到一个webservice:
Dim wsRemote As New System.ServiceModel.EndpointAddress("http://www.exampleurl.com/example.asmx")
Dim wsBinding As System.ServiceModel.Channels.Binding = Nothing
Dim wsListenerBindingClass As Type = Nothing
wsListenerBindingClass = GetType(System.ServiceModel.BasicHttpBinding)
wsBinding = DirectCast(Activator.CreateInstance(wsListenerBindingClass), System.ServiceModel.Channels.Binding)
Dim m_wsTest As wsExample.WebServiceSoapClient = New wsExample.WebServiceSoapClient(wsBinding, wsRemote)m_wsTest类实例提供了几种基于xml的信息检索方法。如果字符串的总大小超过8192 (默认值),则i(显然)将得到以下错误消息:
格式化程序在试图反序列化消息时抛出一个异常:试图反序列化参数Test.ExampleWebservice:GetInfoResponse时出错。该InnerException消息是“反序列化Test.ExampleWebservice.wsTest.GetInfoResponseBody.类型的对象时出错--读取InnerException数据时超过了最大字符串内容长度配额(8192)。在创建XmlDictionaryReaderQuotas读取器时,可以通过更改XmlDictionaryReaderQuotas对象上的MaxStringContentLength属性来增加此配额。”有关更多细节,请参见InnerException。
我理解这个错误信息意味着什么和我必须做什么(增加配额),但根本找不到你在哪里和如何做到这一点。所以,我需要你帮忙。
注意:我不想在安装中包含".exe.config“文件。我想要没有它的连接,只是通过代码。
注意:我理解C#和VB.NET,所以代码示例可能出现在这两个例子中。
发布于 2012-10-31 09:16:31
您需要用所需的长度初始化ReaderQuotas,并将其分配给绑定。
var readerqts = new XmlDictionaryReaderQuotas();
readerqts.MaxStringContentLength = 20000;
wsListenerBindingClass.ReaderQuotas = readerqts;或者,如果您正在使用HTTPWebRequest通过WebService,您可以使用,
HTTPWebRequest.ContentLength = 10000;https://stackoverflow.com/questions/13154396
复制相似问题