开发者

Ksoap2 2.5.4 and HttpsTransportSE vs AndroidHttpTransport

开发者 https://www.devze.com 2023-03-02 23:56 出处:网络
This works fine but AndroidHttpTransport is deprecated: AndroidHttpTransport t = new AndroidHttpTransport(\"http://a.com/service.asmx\");

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;
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号