Ksoap2 2.5.4 and HttpsTransportSE vs AndroidHttpTransport
This works fine but AndroidHttpTransport is deprecated:
AndroidHttpTransport t = new AndroidHttpTransport("http://a.com/service.asmx");
t.call(action, envelope);
T开发者_如何学JAVAhis gives SSLProtocolException (but I don't want use SSL):
HttpsTransportSE t = new HttpsTransportSE("a.com", 80, "/service.asmx", timeout);
t.call(action, envelope);
HttpTransportSE(String url) should work.
The same question with fhucho :HttpTransportSE(String url)
is not in 2.5.4,
there is HttpTransportSE(host,port,filaname,timeout)
This piece of code works for me, it should for you as well:
String webServiceResponse = null; SoapObject result = null;
String url ="http://a.com/service.asmx";
String soapaction = namespace + method;
SoapObject request_login = new SoapObject(namespace, method);
request.addProperty(<field_name>, <value>);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
try {
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(
url);
androidHttpTransport.call(soapaction, envelope);
if (envelope.bodyIn instanceof SoapFault) {
String str = ((SoapFault) envelope.bodyIn).faultstring;
Log.i("", str);
webServiceResponse = null;
} else {
result_login_String = (SoapObject) envelope.bodyIn;
webServiceResponse = result.getProperty(0)
.toString();
}
} catch (Exception e) {
webServiceResponse = null;
}
精彩评论