String namespace = "****"; // 命名空间,即服务器端得接口,注:后缀没加.wsdl,
String url = "****"; // 对应的webService url
String methodName = "methodName";
SoapObject soapObject = new SoapObject(namespace, methodName);
// soapObject.addProperty("filename", fileName); // 参数1 名
soapObject.addProperty("file", uploadBuffer); // 参数1 字符串
soapObject.addProperty("key",value); // 参数 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.bodyOut = soapObject;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
envelope.setOutputSoapObject(soapObject);
try {
HttpTransportSE httpTranstation = new HttpTransportSE(url, 60000);
httpTranstation.call(namespace + "/" + methodName, envelope);
Object result = (Object) envelope.getResponse();
Log.i("====", result.toString());
if (result.toString().contains("SUCCESS")) {
dosth. } else {
dosth. }
} catch (IllegalArgumentException e) {
Log.i("====", "time out");
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
closeCurrentDialog();
}
前几天出现个问题,把webservice 换了服务器,但是返回来的字符串就乱码了 到了
Object result = (Object) envelope.getResponse();
出错,上网查了一些资料,说是吧2.6.5的jar换成 2.5.7就可以了,试了一下,果然解决问题。
这个可能是 2.6.5的bug吧,我把2.5.7的jar 也发上来共享下!