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));