与ksoap2在Android上发送的字节数组 [英] Sending byte array with ksoap2 on android

查看:67
本文介绍了与ksoap2在Android上发送的字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Android设备的图像上传到WCF服务。如果我送小图像(约20KB),那么它工作正常。如果我发送一个稍大的图像(约95KB)我得到一个错误:

I'm trying to upload images from an android device to a WCF service. If I send a small image (about 20kb) then it works fine. If I send a slightly larger image (about 95kb) I get an error:

org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@41636470)

Android的code是:

Android code is:

    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绑定:

The exception is thrown on the androidHttpTransport.call line after a few seconds. The breakpoint in my WCF service is never hit. I've upped the request limits on the WCF bindings:

  <basicHttpBinding>
    <binding name="MobileIntegrationBinding" messageEncoding="Text" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
      <security mode="Transport" />
    </binding>
  </basicHttpBinding>

有数据KSOAP将添加到财产数额的一些限制,如果是的话,有没有办法来提高呢?

Is there some limit on the amount of data KSOAP will add to a property, and if so is there a way to increase this?

推荐答案

嗯,知道了到底。我的绑定和服务的声明都搞砸在web.config中,所以我的变化maxReceivedMessageSize等人没有因为服务是用我自定义的使用,而不是默认绑定任何影响。

Ah, got it in the end. My bindings and service declaration were all messed up in the web.config, and so my changes to maxReceivedMessageSize etc weren't having any effect because the service was using the default bindings instead of using my custom one.

这篇关于与ksoap2在Android上发送的字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆