GVillani82
GVillani82

Reputation: 17429

Close http connection after web service call, in Android

How can I close connection opened by the following code:

 HttpTransportSE androidHttpTransport = new HttpTransportSE(URL)
 androidHttpTransport.call(soap_action, envelope);

HttpTransportSE is a class defined in Ksoap2 library.

Upvotes: 1

Views: 2299

Answers (3)

Yaseen
Yaseen

Reputation: 26

        if(httpTransport!=null){
            httpTransport.reset();
            try {
                httpTransport.getConnection().disconnect();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

Upvotes: 1

Swayam
Swayam

Reputation: 16364

Cancel the AsyncTask inside which you are creating the connection as the cancelled AsyncTask will stop all the processes running inside it and hence your connection would get closed too.

mAsyncTask.cancel(true);

Upvotes: 0

Bertie Wheen
Bertie Wheen

Reputation: 1243

androidHttpTransport.reset();

?

See here

Upvotes: 1

Related Questions