簡體   English   中英

Ksoap2 2.5.4 和 HttpsTransportSE 與 AndroidHttpTransport

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM