我正在尝试使用 Ksoap2 从 Android 发送 .jpeg 图像,但是我尝试过的所有操作都收到错误消息“无法序列化”,这就是我正在做的事情:
ByteArrayOutputStream out = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG, 100, out);
byte[] raw = out.toByteArray();
String encodedImage = Base64.encodeToString(raw, Base64.DEFAULT);
SoapObject request = new SoapObject("http://tempuri.org/", "sendImage");
request.addProperty("image", out);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
Toast.makeText(getApplicationContext(), "Sending Pic", Toast.LENGTH_LONG).show();
HttpTransportSE androidHttpTransport = new HttpTransportSE("http://www.letstrend.com/spursService.asmx?WSDL");
androidHttpTransport.call("http://tempuri.org/sendImage", envelope);
SoapObject result = (SoapObject)envelope.bodyIn;
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "in catch e=" + e.getMessage(), Toast.LENGTH_LONG).show();
}
我已经尝试发送原始和编码图像,但都以错误的形式返回。out 实际上是我认为它应该看起来的样子,也是我认为我的 .Net web 服务所期望的。网络服务期望:
<myImage>base64Binary</myImage>
有任何想法吗?谢谢。