0
我正在通过Mozilla浏览器通过Mozilla客户端访问REST Web服务。 (在web服务在Android客户端的其他Web服务中提供授权
后端弹簧安全已配置并且对于每个
请求证书进行验证)。所以我设置基本身份验证(用户名和密码)和
请求标头“应用程序/ json”这很好。
现在我想通过Android应用程序连接到这个Web服务如下。我如何设置
用户(用户名和密码)的凭证?
@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));