图片上传到服务器 [英] Uploading image to the server
问题描述
由于我的项目的一部分,我需要将图像上传到服务器。在服务器部分我有一个Web服务,将接受字节数组和转换中的形象。在我的客户端部分(Android版+ ksoap2)我转换的图像使用Base64编码为byte []数组。但我不能错过的字节数组到Web服务。它呈现出一些序列化的问题。
我如何使用ksoap2.Somebody字节数组传递到Web服务,请帮助我.....
As part of my project I need to upload an image to the server. In the server part I have a web service that will accept byte array and converting in to image. In my client part(Android + ksoap2) I converted the image to byte[] array using Base64 encoding. But I could not pass the byte array to the web service. It is showing some serialization problem. How can I pass the byte array to the web service using ksoap2.Somebody please help me.....
推荐答案
尝试用这个code
使用序列化的字节数组 MarshalBase64
Serialize byte array using MarshalBase64
MarshalBase64 marshal = new MarshalBase64();
ByteArrayOutputStream out = new ByteArrayOutputStream();
bmp.compress(CompressFormat.PNG, 100, out);
byte[] raw = out.toByteArray();
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
OPERATION_NAME);
request.addProperty("image", raw);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
marshal.register(envelope);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
使用Android的KSOAP 序列化的字节数组>
这篇关于图片上传到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!