我正在尝试将图像从 android 设备上传到 WCF 服务。如果我发送一个小图像(大约 20kb),那么它工作正常。如果我发送稍微大一点的图像(大约 95kb),我会收到一个错误:
org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@41636470)
安卓代码是:
byte[] fileContents = IOUtil.readFile(image.getFileName());
request = new SoapObject(CommonFunctions.NAMESPACE, "SaveAttachment");
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
new MarshalBase64().register(envelope);
androidHttpTransport = new HttpTransportSE(CommonFunctions.SERVICE_URL);
request.addProperty("SomeProperty1", somevalue1);
request.addProperty("SomeProperty2", somevalue2);
PropertyInfo p1=new PropertyInfo();
p1.setName("FileContents");
p1.setType(MarshalBase64.BYTE_ARRAY_CLASS);
p1.setValue(fileContents);
request.addProperty(p1);
androidHttpTransport.call(CommonFunctions.SOAP_ACTION + "SaveAttachment", envelope);
int fileId = Integer.parseInt(envelope.getResponse().toString());
几秒钟后在 androidHttpTransport.call 行上抛出异常。我的 WCF 服务中的断点永远不会被命中。我提高了 WCF 绑定的请求限制:
<basicHttpBinding>
<binding name="MobileIntegrationBinding" messageEncoding="Text" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<security mode="Transport" />
</binding>
</basicHttpBinding>
KSOAP 将添加到属性的数据量是否有一些限制,如果是,有没有办法增加这个?