Android里ksoap2调用WebService

2014-11-24 10:38:56 ? 作者: ? 浏览: 0

定义了soap_action=http://192.168.1.111:8080/hy/webservice/HyDataWrapperWSService


和soap_url = http://192.168.1.111:8080/hy/webservice/HyDataWrapperWSService wsdl


call的时候androidHttpTransport.call(soap_action, envelope);要把soap_action传进去。


后来用cxf改写了WebService了,android一直报错。


java.lang.ClassCastException: org.ksoap2.SoapFault。不知道愿意。


然后看到网上有人call的时候,soap_action用的是null。


androidHttpTransport.call(null, envelope);


结果却正常调用下去了。不知道为什么。



SoapObject request = new SoapObject(NAMESPACE, methodname);


// 调用的参数


Iterator it = parameter.keySet().iterator();


while (it.hasNext()) {


String key = it.next().toString();


request.addProperty(key, parameter.get(key));


}



SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(


SoapEnvelope.VER11);


envelope.setOutputSoapObject(request);


try {


// 调用SOAP


HttpTransportSE androidHttpTransport = new HttpTransportSE(url,


10000);


androidHttpTransport.debug = true;


//


//androidHttpTransport.call(soap_action, envelope);



androidHttpTransport.call(null, envelope);


Log.d("invoke", "0");


// 获得SOAP调用的结果


SoapObject result = (SoapObject) envelope.bodyIn;


Log.d("invoke", "1");


if (result != null) {


response = result.getProperty(0).toString();


}


Log.d("invoke", "2");


return response;



} catch (Exception e) {


e.printStackTrace();


Log.d("Exception", "timeout");


throw new ApplicationException(e,


context.getString(R.string.soap_error));


}


-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: