anyone help me how to POST authentication details to a restful web service and to get response from it. I have to post Username, IsAuthenticated(ie. true or false), Password.Als
And I got the answer finally and working fine for me... I have posted the working code below.
public class LoginActivity extends Activity
{
String Returned;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost("http://Your url here/");
StringEntity str = new StringEntity("Your xml code");
str.setContentType("application/xml; charset=utf-8");
str.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/xml; charset=utf-8"));
post.setEntity(str);
HttpResponse response = httpclient.execute(post);
HttpEntity entity = response.getEntity();
Returned = EntityUtils.toString(entity);
Toast.makeText(this, Returned, Toast.LENGTH_LONG).show();
} catch ( IOException ioe ) {
ioe.printStackTrace();
}
}
}
thanks a lot for all your responses.