java.lang.RuntimeException:无法序列化

java.lang.RuntimeException:无法序列化,java,android,web-services,android-asynctask,ksoap2,Java,Android,Web Services,Android Asynctask,Ksoap2,我已经编写了使用web服务Mehod SaveOrder的代码。代码如下所示 public final String SOAP_ACTION = "http://tempuri.org/SaveOrder"; public final String OPERATION_NAME = "SaveOrder"; public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/"; // public final String SO

我已经编写了使用web服务Mehod SaveOrder的代码。代码如下所示

public final String SOAP_ACTION = "http://tempuri.org/SaveOrder";

public final String OPERATION_NAME = "SaveOrder";

public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

// public final String SOAP_ADDRESS =
// "http://mspldevad.cloudapp.net/order/Service.asmx";

// public final String SOAP_ADDRESS = "http://10.10.10.5:1212/Service.asmx";
public final String SOAP_ADDRESS = "http://10.10.10.5:101/Service.asmx";


public String SaveOrder(String Userid, String Latlong, String LocationID,
        String LabCount, String LabCodes, String IsOrder, byte[] image,
        String TubeCount) {

    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);

    PropertyInfo pi = new PropertyInfo();
    pi.setName("Userid");
    pi.setValue(Userid);
    pi.setType(String.class);
    request.addProperty(pi);

    pi = new PropertyInfo();
    pi.setName("Latlong");
    pi.setValue(Latlong);
    pi.setType(String.class);
    request.addProperty(pi);

    pi = new PropertyInfo();
    pi.setName("LocationID");
    pi.setValue(LocationID);
    pi.setType(String.class);
    request.addProperty(pi);

    pi = new PropertyInfo();
    pi.setName("LabCount");
    pi.setValue(LabCount);
    pi.setType(String.class);
    request.addProperty(pi);

    pi = new PropertyInfo();
    pi.setName("LabCodes");
    pi.setValue(LabCodes);
    pi.setType(String.class);
    request.addProperty(pi);

    pi = new PropertyInfo();
    pi.setName("IsOrder");
    pi.setValue(IsOrder);
    pi.setType(String.class);
    request.addProperty(pi);

    pi = new PropertyInfo();
    pi.setName("image");
    pi.setValue(image);
    pi.setType(byte[].class);
    request.addProperty(pi);


    pi = new PropertyInfo();
    pi.setName("TubeCount");
    pi.setValue(TubeCount);
    pi.setType(String.class);
    request.addProperty(pi);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
    Object response = null;
    try {

        httpTransport.call(SOAP_ACTION, envelope);
        response = envelope.getResponse();
    } catch (Exception exception) {
        response = exception.toString();
    }
    return response.toString();
}
代码正在引发异常java.lang.RuntimeException:无法序列化:[B@40e42ec0

在httpTransport.call行中(SOAP\u操作,信封)


有什么建议吗?

当它说
无法序列化时:[B@40e42ec0
它告诉您它无法序列化
字节[]
对象

事实上,我认为问题在于您正在使用
byte[].class
来指定
图像
PropertyInfo
对象中的类型

根据另一个问答,它应该是
MarshalBase64.BYTE\u ARRAY\u CLASS

参考:

    • 你可以像这样做

      Base64.encode(your Byte array variable)
      
      例如,在发送时

      request.addProperty("Picture", Base64.encode(bmp100));
      

      我已经解决了这个问题,希望它能帮助您

      向我们展示stacktrace.trued pi.setType(MarshalBase64.BYTE\u ARRAY\u类),但引发了相同的异常java.lang.RuntimeException:无法序列化:[B@40de2fd0