title: Android Web Services Using Rest - Error In SOAP Message
body: <p>I'm having a problem with getting a simple output from a web service using Android RESTful consumer. Below is my code and my output. However, I cannot seem to get a value returned from this web service. <a href="http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit" rel="nofollow">http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit</a></p>
  
  <p>I'd greatly appreciate it if anyone can help me figuring out why it says in the SOAP message </p>
  
  <pre><code>"Server was unable to process request. ---&amp;gt; Data at the root level is      
  invalid"
  </code></pre>
  
  <p>My Code Compiles And Runs Fine</p>
  
  <pre><code>public class MainActivity extends Activity {
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
  
      BufferedReader in = null;
      try {
          HttpClient client = new DefaultHttpClient();
          HttpPost request = new HttpPost(
                  "http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit");
  
          List&lt;NameValuePair&gt; postParameters = new ArrayList&lt;NameValuePair&gt;();
          postParameters.add(new BasicNameValuePair("param1", "77"));
          UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
          request.setEntity(formEntity);
  
          HttpResponse response = client.execute(request);
  
          in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
          StringBuffer sb = new StringBuffer("");
          String line = "";
          String NL = System.getProperty("line.separator");
          while ((line = in.readLine()) != null) {
              sb.append(line + NL);
          }
          in.close();
  
          String page = sb.toString();
          // Log.i(tag, page);
          System.out.println(page);
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          if (in != null) {
              try {
                  in.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  }
  </code></pre>
  
  <p>My Output</p>
  
  <pre><code>09-08 14:25:25.383: I/System.out(1620): &lt;?xml version="1.0" encoding="utf-8"?&gt;   
  &lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soap:Body&gt;&lt;soap:Fault&gt;&lt;soap:Code&gt; 
  &lt;soap:Value&gt;soap:Receiver&lt;/soap:Value&gt;&lt;/soap:Code&gt;&lt;soap:Reason&gt;&lt;soap:Text   
  xml:lang="en"&gt;Server was unable to process request. ---&amp;gt; Data at the root level is  
  invalid. Line 1, position 1.&lt;/soap:Text&gt;&lt;/soap:Reason&gt;&lt;soap:Detail /&gt;&lt;/soap:Fault&gt; 
  &lt;/soap:Body&gt;&lt;/soap:Envelope&gt;
  
  09-08 14:25:25.863: D/gralloc_goldfish(1620): Emulator without GPU emulation detected.
  09-08 14:30:00.076: I/Choreographer(1620): Skipped 35 frames!  The application may be doing too much work on its main thread.
  </code></pre>