[英]Ksoap2 2.5.4 and HttpsTransportSE vs AndroidHttpTransport
這工作正常,但 AndroidHttpTransport 已棄用:
AndroidHttpTransport t = new AndroidHttpTransport("http://a.com/service.asmx");
t.call(action, envelope);
這給出了 SSLProtocolException (但我不想使用 SSL):
HttpsTransportSE t = new HttpsTransportSE("a.com", 80, "/service.asmx", timeout);
t.call(action, envelope);
HttpTransportSE(String url) 應該可以工作。
與fhucho:HttpTransportSE(String url)
不在 2.5.4 中,有HttpTransportSE(host,port,filaname,timeout)
這段代碼對我有用,它也應該對你有用:
字符串 webServiceResponse = null; SoapObject 結果 = 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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.