Firstly, you can create a String template for this SOAP request and substitute user-supplied values at runtime in this template to create a valid request. Wrap this string in a StringEntity and set its content type as text/xml Set this entity in the SOAP request. Something like: HttpPost httppost = new HttpPost(SERVICE_EPR); StringEntity 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); response. Put("HTTPStatus",httpResponse.getStatusLine().toString()).
You should also consider reading this: stackoverflow. Com/questions/297586/… – Samuh Apr 1 '10 at 12:12 Thanks that worked, much cleaner, although I had to a add a 'HttpClient httpclient = new DefaultHttpClient();' – Intosia Apr 1 '10 at 13:19 2 Of course, I just pasted the portion relevant to the point I was making... glad to know it helped. Cheers!
– Samuh Apr 1 '10 at 16:30 1 hi. Should I put SOAPRequestXML = "POST /a8103e.... " or "– Foysal Apr 1 '10 at 10:18.
Here the alternative to send soap msg. Public String setSoapMsg(String targetURL, String urlParameters){ URL url; HttpURLConnection connection = null; try { //Create connection url = new URL(targetURL); // for not trusted site (https) // _FakeX509TrustManager.allowAllSSL(); // System. SetProperty("javax.net.
Debug","all"); connection = (HttpURLConnection)url.openConnection(); connection. SetRequestMethod("POST"); connection. SetRequestProperty("SOAPAction", "**** SOAP ACTION VALUE HERE ****"); connection.
SetUseCaches (false); connection. SetDoInput(true); connection. SetDoOutput(true); //Send request DataOutputStream wr = new DataOutputStream ( connection.
GetOutputStream ()); wr. WriteBytes (urlParameters); wr. Flush (); wr.
Close (); //Get Response InputStream is ; Log. I("response", "code="+connection.getResponseCode()); if(connection.getResponseCode()Append(line); response. Append('\r'); } rd.close(); Log.
I("response", ""+response.toString()); return response.toString(); } catch (Exception e) { Log. E("error https", "", e); return null; } finally { if(connection! = null) { connection.disconnect(); } } } hope it helps.
If anyone wonder allowAllSSL() method, google it :).
Here's my code for sending HTML.... You can see the data is the nameValuePairs. Add(...) HttpClient httpclient = new DefaultHttpClient(); // Your URL HttpPost httppost = new HttpPost("192.71.100.21:8000"); try { List nameValuePairs = new ArrayList(2); // Your DATA nameValuePairs. Add(new BasicNameValuePair("id", "12345")); nameValuePairs.
Add(new BasicNameValuePair("stringdata","AndDev is Cool! ")); httppost. SetEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response; response = httpclient.
Execute(httppost); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }.
I had to send some XML via HTTP Post on Android too. String xml = "xml-block"; StringEntity se = new StringEntity(xml,"UTF-8"); se. SetContentType("application/atom+xml"); HttpPost postRequest = new HttpPost("http://some.
Url"); postRequest. SetEntity(se); Hope it works!
So if you use: httppost. SetEntity(new UrlEncodedFormEntity(nameValuePairs)); is still rest, but if you use: StringEntity se = new StringEntity(SOAPRequestXML,HTTP. UTF_8); httppost.
SetEntity(se); Is soap?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.