【发布时间】:2016-08-23 23:42:31
【问题描述】:
我使用 KSOAP2 但我希望使用 Volley 并且我无法使用身份验证连接 Web 服务。 我已经尝试覆盖方法 getHeader 但在日志中显示以下内容。
E/Volley: [593] BasicNetwork.performRequest: Unexpected response code 500 for http://myservice/register.asmx
这是我的代码:
public void peticion() {
final RequestQueue queue = Volley.newRequestQueue(this);
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.e("response", response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("VolleyError", error.getMessage());
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<String, String>();
headers.put("UsuarioName", "user123");
headers.put("UsuarioPass", "123456789");
return headers;
}
};
queue.add(stringRequest);
}
编辑 对我的 WebService 进行分段
<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/MLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> <Autenticacion xmlns="http://tempuri.org/"> <suarioPass>string</UsuarioPass> <UsuarioName>string</UsuarioName> </Autenticacion> </soap12:Header>
使用 ksoap 工作,但没有截击。
-数据正确
-服务工作
我不明白为什么不使用 volley
感谢您的帮助
【问题讨论】:
-
尝试使用
getBody而不是getHeaders -
@BNK 例如:stackoverflow.com/a/26270185/3741698 ?
标签: android android-volley ksoap2