Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>check the following example it should work </p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); } private void init() { //your webservice envelope String envelope="&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;GetContentTreeBySections xmlns=\"http://tempuri.org/\"&gt;&lt;SectionsInclude&gt;%s&lt;/SectionsInclude&gt;&lt;DocumentCount&gt;%s&lt;/DocumentCount&gt;&lt;SortBy&gt;%s&lt;/SortBy&gt;&lt;SortOrder&gt;%s&lt;/SortOrder&gt;&lt;UserName&gt;%s&lt;/UserName&gt;&lt;Pass&gt;%s&lt;/Pass&gt;&lt;/GetContentTreeBySections&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;"; String myEnvelope = String.format(envelope, "myParam1 value", "myParam2 value","myParam3 value","myParam4 value"); String url = "http://www.mywebserice.com/XMLGenerator/GenerateXML.asmx"; String soapAction = "http://tempuri.org/GetContentTreeBySections"; String response = CallWebService(url, soapAction, myEnvelope); //Log.v("response", response); Toast.makeText(getApplicationContext(), "this"+response,Toast.LENGTH_LONG).show(); String xml=response; } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } String CallWebService(String url,String soapAction,String envelope) { final DefaultHttpClient httpClient=new DefaultHttpClient(); // request parameters HttpParams params = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, 10000); HttpConnectionParams.setSoTimeout(params, 15000); // set parameter HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), true); // POST the envelope HttpPost httppost = new HttpPost(url); // add headers httppost.setHeader("soapaction", soapAction); httppost.setHeader("Content-Type", "text/xml; charset=utf-8"); String responseString=""; try { // the entity holds the request HttpEntity entity = new StringEntity(envelope); httppost.setEntity(entity); // Response handler ResponseHandler&lt;String&gt; rh=new ResponseHandler&lt;String&gt;() { // invoked when client receives response public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException { // get response entity HttpEntity entity = response.getEntity(); // read the response as byte array StringBuffer out = new StringBuffer(); byte[] b = EntityUtils.toByteArray(entity); // write the response byte array to a string buffer out.append(new String(b, 0, b.length)); return out.toString(); } }; responseString=httpClient.execute(httppost, rh); } catch (Exception e) { Log.v("exception", e.toString()); } // close the connection httpClient.getConnectionManager().shutdown(); return responseString; } </code></pre>
    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.
    1. This table or related slice is empty.
    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