Could you please advice a Server against which I can test my Class which sends and receives a response to httpPost() method?
Heres a free site:
http://www.snee.com/xml/crud/posttest.html
You can post to http://www.snee.com/xml/crud/posttest.cgi
with two parameters put them as your key
fname
and lname
and will display the response.
Heres the entire source of the form
<html>
<title>POST test</title>
<body>
<h1>posttest.html</h1>
<form action="posttest.cgi" method="post">
<p>This form invokes an existing script called posttest.cgi:</p>
<p>first name <input type="text" name="fname" size="40"/></p>
<p>last name <input type="text" name="lname" size="40"/></p>
<input type="submit" value=" go " />
</form>
</body></html>
Of coarse you can go to that site and check it out. Hope that helps
Heres a sample android code:
try{
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(
"http://www.snee.com/xml/crud/posttest.cgi");
List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("fname", "First name"));
postParameters.add(new BasicNameValuePair("lname", "Last name"));
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();}catch(Exception ex){}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With