我如何在异步任务中进行ksoap2调用?

问题描述 投票:1回答:2

我是android开发的新手。我正在尝试开发一个将与.net webservice连接以便检索数据的应用程序。我想用AsyncTask进行ksoap2调用。我如何用asynctask命名为asyncronus

我的SoapCall类是

public class SoapCall {

public final static String SOAP_ACTION = "http://www.alpha.net.com/ExecuteEBSCommand";

public final static String OPERATION_NAME = "ExecuteEBSCommand";

public final static String NAMESPACE = "http://www.alpha.net.com";

public final static String URL = "http://192.168.2.100/Ebs2Alpha/Service.asmx";





public String connection(String Command, String CommandParameters) throws Throwable, Throwable {
    String response = null;
    SoapObject Request = new SoapObject(NAMESPACE, OPERATION_NAME);
    Request.addProperty("strCommand", Command);
    Request.addProperty("strCommandParameters", CommandParameters);



    SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    soapEnvelope.dotNet = true;
    soapEnvelope.setOutputSoapObject(Request);
    // Needed to make the internet call

    // Allow for debugging - needed to output the request

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;
        // this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION, soapEnvelope);

        // Get the SoapResult from the envelope body.
        SoapObject result = (SoapObject) soapEnvelope.bodyIn;

        response = result.getProperty(0).toString();


    return response;
    }
}

到目前为止,我通过在主活动中使用以下方法调用连接方法来获得响应:>

SoapCall  call1= new SoapCall();

call1.connection("get_clients", "%");

我是android开发的新手。我正在尝试开发一个将与.net webservice连接以便检索数据的应用程序。我想使用AsyncTask进行ksoap2调用。如何...

android .net web-services android-asynctask ksoap2
2个回答
2
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.