android 调用webservice出错

引用第三方ksoap2的jar包

 SoapObject rpc = new SoapObject(nameSpace, method);

 // 设置需调用WebService接口需要传入的两个参数mobileCode、userId
//        rpc.addProperty("loginName", name);
//        rpc.addProperty("loginPsw", "62c8ad0a15d9d1ca38d5dee762a16e01");
LoginRequestData requestData = new LoginRequestData();
requestData.setLoginName(name);
requestData.setLoginPsw(pwdMD5);
rpc.addProperty("arg0", requestData);
//PropertyInfo objekt = new PropertyInfo();
//objekt.setName("arg0");
//objekt.setValue(requestData);
//objekt.setType(requestData.getClass());
//rpc.addProperty(objekt);

// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.bodyOut = rpc;
// 设置是否调用的是dotNet开发的WebService
envelope.dotNet = false;
// 等价于envelope.bodyOut = rpc;
envelope.setOutputSoapObject(rpc);

HttpTransportSE transport = new HttpTransportSE("http://" + application.getIp() +
                        "/business/CXF/business" + "?wsdl");


 transport.debug = true;
 // 调用WebServiced
  // 获取返回的数据
//            SoapObject object = (SoapObject) envelope.bodyIn;
SoapObject object = (SoapObject) envelope.getResponse();
//            result = object.getProperty(0).toString();
// 获取返回的结果
String result = envelope.getResponse().toString();

尤其要注意如果后台是.net envelope.dotNet = true; 这句一定要设置成true ,java或其他平台要设置成false否则会出下面的错误

SoapFault - faultcode: ‘soap:Server’ faultstring: ‘Fault occurred while processing.’ faultactor: ‘null’ detail: null

©️2020 CSDN 皮肤主题: 精致技术 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值