title: Calling Soap webservice from android
body: <p>I am using the below process,</p>
  
  <p>1)Create a String template for a SOAP request and substitute user-supplied values at     runtime in this template to create a valid request.
     2) Wrap this string in a StringEntity and set its content type as text/xml
     3) Set this entity in the SOAP request.</p>
  
  <p>and with the help of httppost I am posting the request,</p>
  
  <p>I am using a demo webservice from w3schools.com</p>
  
  <p>url---></p>
  
  <p><a href="http://www.w3schools.com/webservices/tempconvert.asmx" rel="nofollow">http://www.w3schools.com/webservices/tempconvert.asmx</a></p>
  
  <p>What I have tried is,</p>
  
  <pre><code>HttpPost httppost = new HttpPost("http://www.w3schools.com/webservices/tempconvert.asmx");          
          StringEntity se;
          try {
              SOAPRequestXML="&lt;soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\"&gt;&lt;soapenv:Header/&gt;&lt;soapenv:Body&gt;&lt;tem:CelsiusToFahrenheit&gt;&lt;!--Optional:--&gt;&lt;tem:Celsius&gt;30&lt;/tem:Celsius&gt;&lt;/tem:CelsiusToFahrenheit&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;";
              Log.d("request is ", SOAPRequestXML+"!!!");
              se = new StringEntity(SOAPRequestXML,HTTP.UTF_8);
  
  
          se.setContentType("text/xml");  
          httppost.setHeader("Content-Type","application/soap+xml;charset=UTF-8");
          httppost.setEntity(se);  
  
          HttpClient httpclient = new DefaultHttpClient();
          BasicHttpResponse httpResponse = 
              (BasicHttpResponse) httpclient.execute(httppost);
          HttpEntity resEntity = httpResponse.getEntity();
          t.setText(EntityUtils.toString(resEntity));
  
  
  
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  </code></pre>
  
  <p>I am able to get the response in soapui, so surely the code is wrong because in emulator I am getting the output,</p>
  
  <p>"the server cannot service the request because the media type is unsupported".</p>
  
  <p>Am I passing the correct parameter in the constructor of HttpPost or am I making the correct xml request.I tried a lot but could not figure it out.</p>
  
  <p>Thanks</p>