I am accessing a REST web service via Mozilla client via Mozilla browser. (In web service
back end spring security has configured and credentials for each
request is validated). So I am setting basic authentication (username and password) and
Request header "application/json" which is fine.
Now I want to connect to this web service via a android application as below. How do I set
credentials of the user (username and password) to the request ?
@Override
protected Void doInBackground(Void... params) {
HttpClient client = new DefaultHttpClient();
WsUrl="http://192.168.0.15:8080/ServiceApp/categoryservice/category/001"; // RESTFUL URL RESOURCE
HttpGet getRequest = new HttpGet(WsUrl);
try {
HttpResponse response=client.execute(getRequest);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if(statusCode != 200){
return null;
}
InputStream jsonStream = response.getEntity().getContent();
ufferedReader reader = new BufferedReader(new InputStreamReader(jsonStream));