我想尝试使用肥皂服务。如果我使用任何不需要任何身份验证的Web服务,请完美地工作,但是当auth与nedded结合时我遇到了问题。
我使用下一个代码,但收到此消息:
com.android.volley.AuthFailureError
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
String url ="http://XXXX";
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// Display the first 500 characters of the response string.
mTextView.setText("Response is: "+ response.substring(0,500));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mTextView.setText("That didn't work!"+error);
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
try {
Map<String, String> map = new HashMap<String, String>();
String key = "Authorization";
String encodedString = Base64.encodeToString(String.format("%s:%s", "USERNAME", "Password").getBytes(), Base64.NO_WRAP);
String value = String.format("Basic %s", encodedString);
map.put(key, value);
return map;
} catch (Exception e) {
Log.e("ERROR", "Authentication Filure" );
}
return super.getParams();
}
};
// Add the request to the RequestQueue.
queue.add(stringRequest);
Logicaly我使用其他服务器,用户并传递..
谢谢!
修改
我尝试使用postman chrome扩展程序连接到webservice,并遇到同样的问题。在调查之后,我发现微软使用其他类型的身份验证来使用名为SPNEGO的Web服务。
我没有找到使用SPNEGOin标题验证的信息..任何想法??