1
我试图在使用Volley的Android上使用托管在IIS中的IIS上的WCF RESTful服务。我有下面的代码:Android Volley在本地主机上使用WCF服务获取错误响应
private static final String URL_BASE = "http://10.0.3.2/SimpleRESTServiceCRUD/BookService.svc";
private static final String URL_JSON = "/Books";
List<Book> items;
JsonObjectRequest jsArrayRequest;
private RequestQueue requestQueue;
public BookAdapter(Context context)
{
super(context,0);
requestQueue = Volley.newRequestQueue(context);
JsonObjectRequest jsArrayRequest = new JsonObjectRequest(
Request.Method.GET,
URL_BASE + URL_JSON,
null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
items = parseJson(response);
notifyDataSetChanged();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "Error on JSON response: " + error.getMessage());
}
}
);
}
但当我总是调试得到new Response.ErrorListener()
但从未进入:
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "Error on JSON response: " + error.getMessage());
}
所以我不知道发生了什么事!我使用Genymotion模拟器,所以我想这尤里斯:
http://192.168.56.1/SimpleRESTServiceCRUD/BookService.svc
http://10.0.3.2/SimpleRESTServiceCRUD/BookService.svc
我竟然用手机浏览器,看看它的工作,而我居然能得到的服务。
如果有人能给我一只手我会很感激。 谢谢!
谢谢@BNK !!!!这是问题所在。根据你的回答,我修改了我的代码之后,出现了错误307,但我更改了IIS中WCF应用程序的位置,并修复了它。谢谢! – josher932