title: ksoap2: Post a soap request according to this request XML
body: <p>My soap request looks like this </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap:Header&gt;
      &lt;Authenticator xmlns="http://www.namespacename.com/services/"&gt;
        &lt;UserName&gt;string&lt;/UserName&gt;
        &lt;Password&gt;string&lt;/Password&gt;
      &lt;/Authenticator&gt;
    &lt;/soap:Header&gt;
    &lt;soap:Body&gt;
      &lt;ListItems xmlns="http://www.namespacename.com/services/"&gt;
        &lt;strCode&gt;string&lt;/strCode&gt;
      &lt;/ListItems&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>I'm at least successfully able to login using ksoap2 but I haven't figured out about the body part, any ideas how to call ListItems with parameter strCode, like it shows above.</p>
  
  <p>Here's the current code.</p>
  
  <pre><code>     String NAMESPACE = "http://www.namespace.com/services/";
       String METHOD_NAME = "ListItems";
       String SOAP_ACTION = "http://www.namespace.com/services/ListItems";
       String URL = "https://www.kupong.se/Services/CouponAPI18.asmx";
  
       SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
  
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                // Enable the below property if consuming .Net service
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
  
        envelope.headerOut = new Element[1];
        envelope.headerOut[0] = buildAuthHeader();
  
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            try 
            {
                androidHttpTransport.call(SOAP_ACTION, envelope, null);
                response = (SoapObject)envelope.getResponse();
  
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }     
  </code></pre>
  
  <p>function for preparing header values for authentication </p>
  
  <pre><code>private Element buildAuthHeader() {
              Element h = new Element().createElement(NAMESPACE, "Authenticator");
  
              Element username = new Element().createElement(NAMESPACE, "UserName");
              username.addChild(Node.TEXT, username);
              h.addChild(Node.ELEMENT, username);
              Element pass = new Element().createElement(NAMESPACE, "Password");
              pass.addChild(Node.TEXT, "password)
              h.addChild(Node.ELEMENT, pass);
  
              return h;
      }
  </code></pre>