title: how to work with soap webservice in android
body: <p>i'm a new user in android. i want to work with a soap webservice. i found very example but they don't work for me :-(</p>
  
  <p>it's url of my webservice :
  <a href="http://parsnerkh.com/webservice/server.wsdl" rel="nofollow">http://parsnerkh.com/webservice/server.wsdl</a>?</p>
  
  <p>and methode name is : Cats</p>
  
  <p>and output is : cat1,cat2,...</p>
  
  <p>it's a test this webservice with php :
  <a href="http://parsnerkh.com/webservice/test-cats.php" rel="nofollow">http://parsnerkh.com/webservice/test-cats.php</a></p>
  
  <p>please help me.</p>
  
  <p>i use this code :</p>
  
  <pre><code>import android.os.AsyncTask;
  import android.os.Bundle;
  import android.app.Activity;
  import org.ksoap2.SoapEnvelope;
  import org.ksoap2.serialization.PropertyInfo;
  import org.ksoap2.serialization.SoapObject;
  import org.ksoap2.serialization.SoapPrimitive;
  import org.ksoap2.serialization.SoapSerializationEnvelope;
  import org.ksoap2.transport.HttpTransportSE;
  import com.example.webserviceactivity.R;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
      private final String NAMESPACE = "urn:AppStore";
      private final String URL = "http://parsnerkh.com/webservice/helloserverwsdl.php";
      private final String SOAP_ACTION = "action:urn:AppStore/AppStorePortType/CatsRequest";
      private final String METHOD_NAME = "Cats";
      private String TAG = "PGGURU";
      private static String celcius;
      private static String fahren;
      Button b;
      TextView tv;
      EditText et;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          //Celcius Edit Control
          et = (EditText) findViewById(R.id.editText1);
          //Fahrenheit Text control
          tv = (TextView) findViewById(R.id.tv_result);
          //Button to trigger web service invocation
          b = (Button) findViewById(R.id.button1);
          //Button Click Listener
          b.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                  //Check if Celcius text control is not empty
                  if (et.getText().length() != 0 &amp;&amp; et.getText().toString() != "") {
                      //Get the text control value
                      celcius = et.getText().toString();
                      //Create instance for AsyncCallWS
                      AsyncCallWS task = new AsyncCallWS();
                      //Call execute 
                      task.execute();
                  //If text control is empty
                  } else {
                      tv.setText("Please enter Celcius");
                  }
              }
          });
      }
  
      public void getFahrenheit(String celsius) {
          //Create request
          SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
          //Property which holds input parameters
          /*PropertyInfo celsiusPI = new PropertyInfo();
          //Set Name
          celsiusPI.setName("Celsius");
          //Set Value
          celsiusPI.setValue(celsius);
          //Set dataType
          celsiusPI.setType(double.class);
          //Add the property to request object
          request.addProperty(celsiusPI);*/
          //Create envelope
  
          SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                  SoapEnvelope.VER11);
          envelope.dotNet = true;
          //Set output SOAP object
          envelope.setOutputSoapObject(request);
          //Create HTTP call object
          HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
  
          try {
              //Invole web service
              androidHttpTransport.call(SOAP_ACTION, envelope);
              //Get the response
              SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
              //Assign it to fahren static variable
              fahren = response.toString();
  
          } catch (Exception e) {
              Log.e("ads","ad");
              e.printStackTrace();
          }
      }
  
      private class AsyncCallWS extends AsyncTask&lt;String, Void, Void&gt; {
          @Override
          protected Void doInBackground(String... params) {
              Log.i(TAG, "doInBackground");
              getFahrenheit(celcius);
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              Log.i(TAG, "onPostExecute");
              tv.setText(fahren + "° F");
          }
  
          @Override
          protected void onPreExecute() {
              Log.i(TAG, "onPreExecute");
              tv.setText("Calculating...");
          }
  
          @Override
          protected void onProgressUpdate(Void... values) {
              Log.i(TAG, "onProgressUpdate");
          }
  
      }
  </code></pre>
  
  <p>and i recive this error :</p>
  
  <pre><code>10-08 22:09:24.536: W/System.err(21468): org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG &lt;/{http://schemas.xmlsoap.org/soap/envelope/}SOAP-ENV:Fault&gt;@2:209 in java.io.InputStreamReader@418ea258) 
  10-08 22:09:24.546: W/System.err(21468):    at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
  10-08 22:09:24.546: W/System.err(21468):    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:138)
  10-08 22:09:24.546: W/System.err(21468):    at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
  10-08 22:09:24.556: W/System.err(21468):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
  10-08 22:09:24.556: W/System.err(21468):    at com.prgguru.android.MainActivity.getFahrenheit(MainActivity.java:85)
  10-08 22:09:24.556: W/System.err(21468):    at com.prgguru.android.MainActivity$AsyncCallWS.doInBackground(MainActivity.java:101)
  10-08 22:09:24.556: W/System.err(21468):    at com.prgguru.android.MainActivity$AsyncCallWS.doInBackground(MainActivity.java:1)
  10-08 22:09:24.556: W/System.err(21468):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
  10-08 22:09:24.556: W/System.err(21468):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
  10-08 22:09:24.556: W/System.err(21468):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
  10-08 22:09:24.556: W/System.err(21468):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
  10-08 22:09:24.556: W/System.err(21468):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
  10-08 22:09:24.556: W/System.err(21468):    at java.lang.Thread.run(Thread.java:856)
  </code></pre>