-3

I have same problem in my soap service

this is my code:

public class WebserviceCall {

    /**
     * Variable Decleration................
     * 
     */
    String namespace = "http://tempuri.org/";
    private String url = "http://192.168.1.50/apps/NotificationService.asmx";

    String SOAP_ACTION;
    SoapObject request = null, objMessages = null;
    SoapSerializationEnvelope envelope;
    AndroidHttpTransport androidHttpTransport;

    WebserviceCall() {
    }


    /**
     * Set Envelope
     */
    protected void SetEnvelope() {

        try {

            // Creating SOAP envelope           
            envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

            //You can comment that line if your web service is not .NET one.
            envelope.dotNet = true;

            envelope.setOutputSoapObject(request);
            androidHttpTransport = new AndroidHttpTransport(url);
            androidHttpTransport.debug = true;

        } catch (Exception e) {
            System.out.println("Soap Exception---->>>" + e.toString());    
        }
    }

    // MethodName variable is define for which webservice function  will call
    public String getConvertedWeight(String MethodName, String nam
           ) 
      {

        try {
            SOAP_ACTION = namespace + MethodName;

            //Adding values to request object
            request = new SoapObject(namespace, MethodName);

            //Adding String value to request object
            request.addProperty("domainname", "" + nam);

            SetEnvelope();

            try {

                //SOAP calling webservice
                androidHttpTransport.call(SOAP_ACTION, envelope);

                //Got Webservice response
                String result = envelope.getResponse().toString();

                return result;

            } catch (Exception e) {
                // TODO: handle exception
                return e.toString();
            }
        } catch (Exception e) {
            // TODO: handle exception
            return e.toString();
        }

    }
    /************************************/
}

Exception is..occurred : android main thread netwark exceptin and write same internet primmisson in mainfest file...and also use ask task class

Thanks in Advance.

Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58

1 Answers1

-1
android main thread Network Exception  Use  this Code in Oncreate of  Webservice Calling Method 

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                .permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }
koutuk
  • 832
  • 1
  • 8
  • 17