13,100
社区成员
发帖
与我相关
我的任务
分享
public byte[] downloadFile(String strUrl, String strFileID)
throws IOException, XmlPullParserException {
byte[] bResponse = null;
HttpTransport ht = null;
try {
System.out.println("----------start---------");
String serviceNamespace = strUrl;
String methodName = "downloadFile";
String serviceURL = strUrl;
SoapObject request = new SoapObject(serviceNamespace, methodName);
request.addProperty("FileID", strFileID);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
(new MarshalBase64()).register(envelope);
ht = new HttpTransport(serviceURL);
ht.debug = true;
ht.call(null, envelope);
bResponse = (byte[])envelope.getResponse(); //这里总是报ClassCastException
} finally {
if (ht != null) {
System.out.println("request dump>>" + ht.requestDump);
System.out.println("response dump>>" + ht.responseDump);
}
}
return bResponse;
}
//原文代码如下:
Object Response = envelope.getResult();
byte[] by = (byte[])Response;
//你的代码
bResponse = (byte[])envelope.getResponse();