title: calling magento web service from android client using kSoap2
body: <p>i am trying to access a magento web service from a android client.which should return a session id.i hav already done this uing java client using apache and am successful in calling the method.
  How ever i am getting xmlpullparser exception when trying with android client as:
  10-24 15:25:44.409: WARN/System.err(277): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {<a href="http://www.w3.org/2001/12/soap-envelope" rel="nofollow noreferrer">http://www.w3.org/2001/12/soap-envelope</a>}Envelope (position:START_TAG @2:327 in java.io.InputStreamReader@44ee2268)</p>
  
  <p>well this is my wsdl file from which i am trying to access login method:<img src="https://i.stack.imgur.com/ZurTi.png" alt="wsdl"></p>
  
  <p>my java code:</p>
  
  <pre><code>public class DeviceClientActivity extends Activity {
  /** Called when the activity is first created. */
  private static final String NAMESPACE = "urn:Magento";
  private static final String URL = "http://xxx.xxx.xx.xxx/magento/index.php/api/v2_soap?wsdl";
  private static final String METHOD_NAME = "login";
  private static final String SOAP_ACTION ="urn:Mage_Api_Model_Server_V2_HandlerAction";
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      Log
      .d("WS",
            "--------------------- Webservice Part Begins ---------------------");  
  Log.d("WS", "1. SoapObject Construction");  
  SoapObject objsoap=new SoapObject(NAMESPACE, METHOD_NAME);  
  </code></pre>
  
  <p>objsoap.addProperty("username", "alokxxxx");<br>
    objsoap.addProperty("apiKey", "xxxxxx");<br>
    Log.d("WS", "Construction of SOAP Object End !!!");   </p>
  
  <pre><code>SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
        SoapEnvelope.VER11); 
  Log.d("WS", "2. Envelop Created");    
  envelope.setOutputSoapObject(objsoap);
  Log.d("WS", "3. Request Into Envelop");
  AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
  httpTransport.debug = true; 
  Log.d("WS", "5. Transport Level to True");
  try {
      httpTransport.call(SOAP_ACTION, envelope);
  </code></pre>
  
  <p>//<strong>error here WARN/System.err(277): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {<a href="http://www.w3.org/2001/12/soap-envelope" rel="nofollow noreferrer">http://www.w3.org/2001/12/soap-envelope</a>}Envelope (position:START_TAG @2:327 in java.io.InputStreamReader@44ee2268)</strong>  </p>
  
  <pre><code>Log.d("WS", "6. httpTransport.call");
      if (envelope != null) 
      {
         SoapObject loresponse = (SoapObject) envelope.getResponse();
         SoapObject logObject = (SoapObject)loresponse.getProperty("sessionId");           
         Log.d("WS", "logObject: "+logObject);                      
      } 
      else 
      {
         Log.d("WS", "Response Envelop Error");
      }
  
  } catch (IOException e) {
      e.printStackTrace();
  } catch (XmlPullParserException e) {
      e.printStackTrace();
  }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>log for your help:
  DEBUG/WS(333): --------------------- Webservice Part Begins ---------------------<br>
  10-29 15:38:33.643: DEBUG/WS(333): 1. SoapObject Construction<br>
  10-29 15:38:33.673: DEBUG/WS(333): Construction of SOAP Object End !!!<br>
  10-29 15:38:33.673: DEBUG/WS(333): 2. Envelop Created 
  10-29 15:38:33.673: DEBUG/WS(333): 3. Request Into Envelop<br>
  10-29 15:38:33.683: DEBUG/WS(333): 5. Transport Level to Trueorg.ksoap2.transport.AndroidHttpTransport@44eeb200
  10-29 15:38:33.683: DEBUG/Try(333): inside try block<br>
  10-29 15:38:34.903: WARN/System.err(333): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {<a href="http://schemas.xmlsoap.org/soap/envelope/" rel="nofollow noreferrer">http://schemas.xmlsoap.org/soap/envelope/</a>}Envelope (position:START_TAG @2:327 in java.io.InputStreamReader@44efbe90)<br>
  any suggestion?
  thanks.</p>