如何在Android中检索Web服务的二进制数据? [英] How to retrieve binary data from Web Service in Android?

查看:109
本文介绍了如何在Android中检索Web服务的二进制数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);          
   Log.d("WebService", "2");
   SoapSerializationEnvelope envelope = 
          new SoapSerializationEnvelope(SoapEnvelope.VER11);
   envelope.dotNet = true;
   envelope.setOutputSoapObject(request);
   HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
   androidHttpTransport.call(SOAP_ACTION, envelope);                    
   SoapPrimitive result = (SoapPrimitive)envelope.getResponse();

这是在code,我叫它发送一个byte []数组.NET Web服务。我怎样才能从byte []数组中的结果变量或有另一种获取byte []数组的方法呢?

This is the code where I call a .NET web service which sends a byte[] array. How can I get the byte[] array from the result variable or is there another approach to retrieve byte[] array?

推荐答案

假设presented code使用kSoap2。如果您要访问的检索数据忘掉用 envelope.getResponse返回的响应对象()

Assuming that the presented code is using kSoap2. If you want to access the retrieved data forget about the response object returned by envelope.getResponse().

您正在寻找能检索到的数据通过

The data you are looking for can retrieved via

SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
if (resultsRequestSOAP != null) {
  Object o = resultsRequestSOAP.getProperty("name of the byte-array parameter");
  // ...
}

返回的对象o通常是类型 SoapPrimitive ,也可以是一个向量

如果它是一个SoapPrimitive使用它的的toString()方法,你可以得到字符串重新字节数组,有要分析的presentation,并转换为字节数组。

If it's a SoapPrimitive using it's toString() method you can get the String representation of the byte array that has to be parsed and converted to a byte array.

如果它是一个载体,我不认为,你将不得不将其转换为字节数组的问题。

If it's a Vector I don't think that you will have problems converting it to a byte array.

这篇关于如何在Android中检索Web服务的二进制数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆