Ksoap2 2.5.4和HttpStranSports与AndroidHttpTransport

Ksoap2 2.5.4和HttpStranSports与AndroidHttpTransport,android,ksoap2,Android,Ksoap2,这很好,但AndroidHttpTransport已被弃用: AndroidHttpTransport t = new AndroidHttpTransport("http://a.com/service.asmx"); t.call(action, envelope); 这提供了SSLProtocolException(但我不想使用SSL): HttpTransportSE(字符串url)应该可以工作。HttpTransportSE(字符串url)应该可以工作。与fhucho相同的问题:Ht

这很好,但AndroidHttpTransport已被弃用:

AndroidHttpTransport t = new AndroidHttpTransport("http://a.com/service.asmx");
t.call(action, envelope);
这提供了SSLProtocolException(但我不想使用SSL):


HttpTransportSE(字符串url)应该可以工作。

HttpTransportSE(字符串url)应该可以工作。

fhucho相同的问题:HttpTransportSE(字符串url)
不在2.5.4中,
HttpTransportSE(主机、端口、filaname、超时)
fhucho相同的问题:HttpTransportSE(字符串url)
不在2.5.4中,
HttpTransportSE(主机、端口、filaname、超时)

这段代码适用于我,也适用于您:

字符串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;
    }
stringurl=”http://a.com/service.asmx";
字符串soapaction=名称空间+方法;
SoapObject请求\ U登录=新的SoapObject(名称空间、方法);
request.addProperty(,);
SoapSerializationEnvelope=新的SoapSerializationEnvelope(
第11版);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求);
试一试{
AndroidHttpTransport AndroidHttpTransport=新AndroidHttpTransport(
网址);
调用(soapaction,信封);
if(SoapFault实例中的envelope.body){
字符串str=((SoapFault)envelope.bodyIn).faultstring;
Log.i(“,str);
webServiceResponse=null;
}否则{
结果\u登录\u字符串=(SoapObject)envelope.bodyIn;
webServiceResponse=result.getProperty(0)
.toString();
}
}捕获(例外e){
webServiceResponse=null;
}

这段代码适合我,也适合你:

字符串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;
    }
stringurl=”http://a.com/service.asmx";
字符串soapaction=名称空间+方法;
SoapObject请求\ U登录=新的SoapObject(名称空间、方法);
request.addProperty(,);
SoapSerializationEnvelope=新的SoapSerializationEnvelope(
第11版);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求);
试一试{
AndroidHttpTransport AndroidHttpTransport=新AndroidHttpTransport(
网址);
调用(soapaction,信封);
if(SoapFault实例中的envelope.body){
字符串str=((SoapFault)envelope.bodyIn).faultstring;
Log.i(“,str);
webServiceResponse=null;
}否则{
结果\u登录\u字符串=(SoapObject)envelope.bodyIn;
webServiceResponse=result.getProperty(0)
.toString();
}
}捕获(例外e){
webServiceResponse=null;
}

HttpTransportSE(字符串url)不在2.5.4中。至少对我来说不是这样:)这很奇怪,我使用的是2.5.4,而HttpTransportSE是可用的。您是否导入了适当的包(org.ksoap2.transport.HttpTransportSE)?HttpTransportSE(字符串url)不在2.5.4中。至少对我来说不是这样:)这很奇怪,我使用的是2.5.4,而HttpTransportSE是可用的。您是否导入了相应的包(org.ksoap2.transport.HttpTransportSE)?