之前jax-ws寫的WebService的時候,Android下通過ksoap2調用的時候,
定義了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));
}