这段代码为Android手机端的java代码                  SoapObject result = null;
try
{
ht.call(_SOAP_ACTION, envelope);
// 用Bodyin读取xml body里面的数据
result = (SoapObject) envelope.bodyIn;
} catch (SoapFault e)
{
e.printStackTrace();
} catch (IOException e)
{
return "IOException:" + e.getMessage();
} catch (XmlPullParserException e)
{
return "XmlPullParserException:" + e.getMessage();
}
// 将base64binary转化为byte[],再进行解压缩,再返回一个字符串
Object tempObject =result.getProperty("compressResult");
byte[] a = ObjectToByte(tempObject);
System.out.println(a);// 将对象转化为byte数组,错误
public byte[] ObjectToByte(java.lang.Object obj)
{
byte[] bytes = null;
try
{
// object to bytearray
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream oo = new ObjectOutputStream(bo);
oo.writeObject(obj); bytes = bo.toByteArray();

bo.close();
oo.close();
} catch (Exception e)
{
e.printStackTrace();
}
return bytes;
}这里把tempObject传入,返回的bytes为空。传来的数据是被服务器端的webservice处理过的byte[]/// <summary>
    /// GZip压缩函数
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public byte[] Compress(byte[] data)
    {
        using (MemoryStream stream = new MemoryStream())
        {
            using (GZipStream gZipStream = new GZipStream(stream, CompressionMode.Compress))
            {
                gZipStream.Write(data, 0, data.Length);
                gZipStream.Close();
            }            return stream.ToArray();
        }
    }public Byte[] NewGetUserDate(string sqlstr)
    {
        sqlconn sqlconn = new sqlconn();
        DataTable selDt = sqlconn.getSelDate(sqlstr);
        String strjson = ToJson.DataTableToJson("json", selDt);        //字符串转换
        byte[] bytejson = System.Text.Encoding.Unicode.GetBytes(strjson); 
        GzipCompress gzipcompress = new GzipCompress();
        byte[] compressedbytejson = gzipcompress.Compress(bytejson);
        return compressedbytejson;
       // return Convert.FromBase64CharArray(compressedbytejson);    }
数据经webservice进行了Gzip压缩后,传入手机端,可以正确获取数据像这样H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/Ir73a/ziX+OjX+P1r/EV/f/3/zWOf40T+u9L+uvFr/Hm,但传入ObjectToByte后,得到的bytes为空