在“我的应用程序”中,我想将图像上传到具有asmx Web服务的Web服务器。在该Web服务中,有两个参数,一个是文件名,另一个是字节数组中的文件。但是当我使用soap api调用它时,它会抛出
异常java.lang.RuntimeException:无法序列化:[B @ 8357037
这是我的android代码,在意图服务类中调用以下方法。
public void uploadFile(String sourceFileUri,String fileName)
{
try
{
File file = new File(imgPath);
byte[] bytesArray = new byte[(int) file.length()];
try
{
FileInputStream fis = null;
fis = new FileInputStream(file);
fis.read(bytesArray); //read file into bytes[]
// fis.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
request.addProperty("f",bytesArray);
request.addProperty("fileName",fileName.toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
Toast.makeText(getBaseContext(), response.toString(),Toast.LENGTH_LONG).show();
}
catch (Exception exception)
{
Toast.makeText(getBaseContext(), exception.toString(),Toast.LENGTH_LONG).show();
}
如何调用asmx服务或如何解决上述异常?