我正在尝试使用volley api将带有xml正文的请求发布到Web服务,但它返回的输出类似于无效的凭据。我是我的代码
StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new com.android.volley.Response.Listener<String>() {
@Override
public void onResponse(String s) {
Log.e("onResponse","...."+s);
}
}, new com.android.volley.Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.e("onErrorResponse","...."+volleyError);
}
}) {
@Override
public String getBodyContentType() {
return "application/xml; charset=" +
getParamsEncoding();
}
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("SLUsername", "uname");
params.put("SLPassword", "pwd");
params.put("CurrentDate", "date");
return params;
}
};
// Schedule the request on the queue
queue.add(stringRequest);
}
下面是我的样本xml正文
<GetDetails>
<SLUsername>Settings Username</SLUsername>
<SLPassword>Settings Password</SLPassword>
<CurrentDate>Settings Date</CurrentDate>
</GetDetails>
如何将此xml主体发送到api?