WCF/Android ksoap2/a:反序列化失败错误,我可以';t更改最大字符串内容长度配额(8192)
我正在编写WCFWebService来处理我的Android项目。我有一个名为CreateOrder的方法,一切正常,直到我注意到,如果我发送的XML数据文件太大,我会出现异常:WCF/Android ksoap2/a:反序列化失败错误,我可以';t更改最大字符串内容长度配额(8192),android,wcf,ksoap2,Android,Wcf,Ksoap2,我正在编写WCFWebService来处理我的Android项目。我有一个名为CreateOrder的方法,一切正常,直到我注意到,如果我发送的XML数据文件太大,我会出现异常: 06-28 15:23:09.894: E/Błąd wątku mainThread / Sender(6988): java.io.IOException: HTTP request failed, HTTP status: 500 然后,我将我的Android项目库从“ksoap2-Android-assemb
06-28 15:23:09.894: E/Błąd wątku mainThread / Sender(6988): java.io.IOException: HTTP request failed, HTTP status: 500
然后,我将我的Android项目库从“ksoap2-Android-assembly-3.0.0-jar-with-dependencies”更改为“ksoap2-Android-assembly-3.0.0-RC.4-jar-with-dependencies”,这就是错误现在的样子:
06-28 15:18:47.124:E/Błąd wątku主线程/发送器(6623):SoapFault
-faultcode:'a:DeserializationFailed'faultstring:'格式化程序在尝试反序列化中的消息:Error时引发异常
正在反序列化操作“CreateOrder”的请求消息体。这个
已超过最大字符串内容长度配额(8192),而
读取XML数据。此配额可以通过更改
XmlDictionaryReaderQuotas上的MaxStringContentLength属性
创建XML读取器时使用的对象。第257行,位置38'
faultactor:“null”详细信息:null
在我意识到发生了什么之后,我改变了配额的大小等。我正在处理这个问题,因为2天内找不到解决方案。也许你们中的一些人认为我的WCF/Config有问题。我也使用了Android/LogCat的方法,但我认为这是WCF的问题
这是我的WCF/App.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647" />
</system.web>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="FoodsoftPortSoap11"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<!--messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"-->
<!--useDefaultWebProxy="true"-->
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<!--<message clientCredentialType="UserName" algorithmSuite="Default" />-->
</security>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="newHTTPBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="basic"
binding="wsHttpBinding"
bindingConfiguration="newHTTPBinding"
contract="FudeoRef.FoodsoftPort"
name="newHTTPBinding">
</endpoint>
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="FoodsoftPortSoap11"
contract="FudeoRef.FoodsoftPort"
behaviorConfiguration="web"
name="FoodsoftPortSoap11" />
</client>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
LogCat
06-28 15:24:26.744:E/Przebieg(6988):1。乌鲁查米亚姆
维西尼亚-扎莫维尼亚:306-2815:24:27.104:V/K(6988):13
2006-2815:24:27.104:V/K(6988):2306-2815:24:27.104:V/K(6988):
罗兹米尔876706-2815:24:27.104:V/K(6988):3306-2815:24:27.104:
V/K(6988):4306-2815:24:27.104:V/K(6988):5306-2815:24:27.104:
E/信封(6988):
org.ksoap2.org。SoapSerializationEnvelope@42d6b658 06-28
15:24:27.104:E/信封(6988):CreateOrder{cXMLData=06-28
15:24:27.104:E/信封(6988):06-28 15:24:27.104:
E/信封(6988):0.06-28 15:24:27.104:
E/信封(6988):06-28 15:24:27.104:
E/信封(6988):100106-2815:24:27.104:
E/信封(6988):06-28
15:24:27.104:E/信封(6988):0…06-28
15:24:27.104:E/K1(6988):
org.ksoap2.org。SoapSerializationEnvelope@42d6b658 06-28
15:24:27.104:V/K(6988):6306-2815:24:27.104:V/K(6988):7306-28
15:24:27.144:D/dalvikvm(6988):全部释放6617K,31%释放
15375K/22168K,暂停30ms,总计32ms 06-28 15:24:27.164:
E/Dodaje(6988):命令306-2815:24:27.164:E/Dodaje(6988):命令4
06-28 15:24:27.174:E/Dodaje(6988):订单506-28 15:24:27.174:
E/多达杰(6988):命令706-2815:24:28.224:I/编舞(6988):
跳过66帧!应用程序可能在其上做了太多工作
主螺纹.06-28 15:24:28.364:E/Bąd wątku主螺纹/
发件人(6988):java.io.IOException:HTTP请求失败,HTTP状态:
五百
您没有在WCF服务配置中定义任何服务端点(您有客户端端点,这没有任何直接意义)。因为您没有定义端点在配置文件中,WCF将显式提供默认端点,以及基于地址方案的默认绑定。在
http://
的情况下,这将是BasicHttpBinding
(除非覆盖配置文件中的协议设置)
因为您得到的是默认绑定,所以您得到的是默认设置,并且您对配置文件中的绑定所做的任何更改都不会应用于服务,除非您a)将其作为该服务的默认绑定配置,或者b)将该配置显式分配给给定端点
要使配置成为给定绑定的默认配置,只需省略name属性:
<bindings>
<webHttpBinding>
<binding closeTimeout="00:01:00"
......
不管这是不是解决方案,我只是建议你一个好的编程实践:你为什么不尝试AsyncTask点击服务器??首先确保wcf客户端可以使用该服务。然后将工作的wcf客户端的请求与android客户端的请求进行比较
<bindings>
<webHttpBinding>
<binding closeTimeout="00:01:00"
......
<services>
<service name="<your service name>">
<endpoint address="basic"
binding="wsHttpBinding"
bindingConfiguration="newHTTPBinding"
contract="FudeoRef.FoodsoftPort"
name="newHTTPBinding" />
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="FoodsoftPortSoap11"
contract="FudeoRef.FoodsoftPort"
behaviorConfiguration="web"
name="FoodsoftPortSoap11" />
</service>
</services>