title: Sending SOAP messages Using KSOAP2 With Android
body: <p>Hi I'm trying to use KSOAP2 2.6.2 android assembly to connect to a java WebService deployed on glassfish 3.1.1. from my android program.
  Here are my Namespaces</p>
  
  <pre><code>public static final String SERVICE_NAMESPACE = "za.co.n7.mobilebackup";
  public static final String SERVICE_URL = "http://ipaddress:8080/MobileBackupServiceImplService/MobileBackupServiceImpl/";
  </code></pre>
  
  <p>Here is My Send Method</p>
  
  <pre><code>    final String METHOD_NAME = "Login";
      SoapObject results = null;
      SoapObject request = null;
      HttpTransportSE loginHttpTransport = null;
      try {
          request = new SoapObject(MBUtil.SERVICE_NAMESPACE, METHOD_NAME);
          request.addProperty("username", username);
          request.addProperty("password", MBUtil.hashPassword(password));
  
          SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                  SoapEnvelope.VER11);
          envelope.bodyOut=request;
          envelope.enc = SoapSerializationEnvelope.ENC;
          envelope.env="http://schemas.xmlsoap.org/soap/envelope/";
  
          // Web method call
          loginHttpTransport = new HttpTransportSE(MBUtil.SERVICE_URL);
          loginHttpTransport.debug = true;
          loginHttpTransport.call(MBUtil.SERVICE_URL + METHOD_NAME, envelope);
  
          results = (SoapObject) envelope.getResponse();
  
          System.out.println("Received Result without issue");
  
      } catch (Exception e) {
          e.printStackTrace();
          System.out.println(loginHttpTransport.requestDump);
          System.out.println(loginHttpTransport.responseDump);
      } finally {
          finish();
      }
  </code></pre>
  
  <p>And I'm getting the following Error in the DDMS LogCat.</p>
  
  <pre><code>04-08 15:30:42.508: W/System.err(1454): org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in   java.io.InputStreamReader@4056c7a8) 
  04-08 15:30:42.508: W/System.err(1454):     at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
  04-08 15:30:42.508: W/System.err(1454):     at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1413)
  04-08 15:30:42.508: W/System.err(1454):     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)
  04-08 15:30:42.508: W/System.err(1454):     at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
  04-08 15:30:42.519: W/System.err(1454):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)
  04-08 15:30:42.519: W/System.err(1454):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
  04-08 15:30:42.519: W/System.err(1454):     at za.co.n7.mobilebackup.LoginActivity.connect(LoginActivity.java:149)
  04-08 15:30:42.519: W/System.err(1454):     at za.co.n7.mobilebackup.LoginActivity$DoLoginRequest.run(LoginActivity.java:116)
  04-08 15:30:42.519: W/System.err(1454):     at android.os.Handler.handleCallback(Handler.java:587)
  04-08 15:30:42.519: W/System.err(1454):     at android.os.Handler.dispatchMessage(Handler.java:92)
  04-08 15:30:42.519: W/System.err(1454):     at android.os.Looper.loop(Looper.java:123)
  04-08 15:30:42.519: W/System.err(1454):     at android.app.ActivityThread.main(ActivityThread.java:3683)
  04-08 15:30:42.519: W/System.err(1454):     at java.lang.reflect.Method.invokeNative(Native Method)
  04-08 15:30:42.519: W/System.err(1454):     at java.lang.reflect.Method.invoke(Method.java:507)
  04-08 15:30:42.519: W/System.err(1454):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  04-08 15:30:42.528: W/System.err(1454):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  04-08 15:30:42.528: W/System.err(1454):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I've copied my SOAP Message and pasted it in soapUI and It gets a result. can anyone assist me, i've been struggling with this for hours now. 
  Here is the sample of my SOAP Message</p>
  
  <pre><code>&lt;v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;v:Header/&gt;
    &lt;v:Body&gt;
        &lt;n0:Login id="o0" c:root="1" xmlns:n0="za.co.n7.mobilebackup"&gt;
           &lt;username i:type="d:string"&gt;umohduke&lt;/username&gt;
           &lt;password i:type="d:string"&gt;c4066ed69b81d6b2b25f76405195c83ddaeecd8dbd3866f17912b895a72bc059&lt;/password&gt;
        &lt;/n0:Login&gt;
     &lt;/v:Body&gt;
  &lt;/v:Envelope&gt;
  </code></pre>