Showing posts with label Android Apps. Show all posts
Showing posts with label Android Apps. Show all posts

April 26, 2012

Resolution: W/System.err(533): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused while running Android App

Issue: W/System.err(533): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused while running Android App.

Resolution: Add following code in AndroidManifest.xml file

<uses-permission android:name="android.permission.INTERNET">  
  after

<uses-sdk android:minSdkVersion="15" />

April 18, 2012

How to call webservice from Android Application (app) using SOAP (ksoap2)

How to call webservice from Android Application (app) using SOAP (ksoap2):
Following is the code snippet through which we can call web service from Android apps using soap with ksoap2 api:
 SoapObject request = new SoapObject(nameSpace, methodName);    
            System.out.println("1");
            String result = "";
            request.addProperty("userName", userName);
            request.addProperty("password", password);
           
            SoapSerializationEnvelope envelope =
                new SoapSerializationEnvelope(SoapEnvelope.VER11);

            envelope.setOutputSoapObject(request);
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

            try {
                androidHttpTransport.call(soapAction, envelope);
                result = ""+envelope.getResponse();
                /*SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
                result = resultsRequestSOAP.toString();*/

                //resultsRequestSOAP.
            } catch (Exception e) {
                e.printStackTrace();
            }