我在Java.lang.RuntimeException: Cannot serialize : -119
执行调用方法时遇到错误:HttpTransportSE
。
我试过直接添加对象:
public String UploadPhotoCall(byte[] imageContent)
SoapObject request = new SoapObject(_wsdlTargetNamespace, _operation);
request.addProperty("imageContent", imageContent);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(_soapAddressLocation);
Object response = null;
try{
httpTransport.call(_action, envelope);
response = envelope.getResponse();
}
catch(IOException ex){
response = ex.toString();
}
catch(Exception ex){
response = ex.toString();
}
阅读主题Pass Array using Web services in Ksoap2后 我试过这个:
SoapObject request = new SoapObject(_wsdlTargetNamespace, _operation);
PropertyInfo propertyImage = new PropertyInfo();
SoapObject soapImage = ByteArrayTransform(imageContent);
propertyImage.setValue(soapImage);
propertyImage.setType(soapImage.getClass());
propertyImage.setName("imageContent");
request.addProperty(propertyImage);
public SoapObject ByteArrayTransform(byte[] image){
SoapObject soapImage = new SoapObject(_wsdlTargetNamespace, _operation);
Log.i(_TAG, "byte array transform begins");
for (int i =0; i < image.length; i++){
soapImage.addProperty(Integer.toString(i), image[i]);
}
return soapImage;
}
但它仍然无济于事。任何人都可以告诉我,如何以正确的方式做到这一点?
答案 0 :(得分:0)
好的,最后我设法解决了这个问题。 添加字节数组以请求在两种方法中都有效,在将SoapObject添加到信封后,它们只缺少一条语句:
new MarshalBase64().register(envelope);
我希望有人觉得它很有用。