Note that there are some explanatory texts on larger screens.

plurals
  1. POSending SOAP request from Android. Server responses: "Server was unable to process request. "
    primarykey
    data
    text
    <p>I try to sent a SOAP query request for Android to the w3schools server, where it converts the temperature from Celsius to Fahrenheit degrees, but I receive the following response from the server:</p> <pre><code>Server was unable to process request. ---&amp;gt; Data at the root level is invalid. Line 1, position 1. </code></pre> <p>The servier is on: <a href="http://w3schools.com/webservices/tempconvert.asmx" rel="nofollow">http://w3schools.com/webservices/tempconvert.asmx</a>. And the SOAP request message structure we can find on: <a href="http://w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit" rel="nofollow">http://w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit</a>. Here is my code.</p> <pre><code>public class MainActivity extends Activity { private static final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx"; TextView tv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); HttpClient httpclient = new DefaultHttpClient(); HttpResponse response; StringBuffer sb = new StringBuffer("" + "POST /webservices/tempconvert.asmx HTTP/1.1" + "Host: w3schools.com" + //"Content-Type: text/xml; charset=utf-8" + //"Content-Length: length" + "SOAPAction: \"http://tempuri.org/CelsiusToFahrenheit\"" + "&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:Body&gt;" + "&lt;CelsiusToFahrenheit xmlns=\"http://tempuri.org/\"&gt;" + "&lt;Celsius&gt;24&lt;/Celsius&gt;" + "&lt;/CelsiusToFahrenheit&gt;" + "&lt;/soap:Body&gt;" + "&lt;/soap:Envelope&gt;"); HttpPost request = new HttpPost(URL); request.setHeader("Content-Type", "application/soap+xml; charset=utf-8"); tv = (TextView) findViewById(R.id.textView1); try { List&lt;NameValuePair&gt; pairs = new ArrayList&lt;NameValuePair&gt;(); pairs.add(new BasicNameValuePair("myxml", sb.toString())); request.setEntity(new UrlEncodedFormEntity(pairs)); response = httpclient.execute(request); String response_string = EntityUtils.toString(response.getEntity()); //Here we should parse the response xml //But for quicker way, we will display the whole response. tv.setText("Temperature in Fahrenheit is: " + response_string); Log.v("responseString", response_string) } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>I would appreciate if you guys could help me out. Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload