相关疑难解决方法(0)

在post post android android volley中发送form-urlencoded参数

我想用表单urlencoded参数创建一个POST JSONObjectRequest.我怎样才能做到这一点?我试过以下代码,但无济于事.

final String api = "http://api.url";
final JSONObject jobj = new JSONObject();
jobj.put("Username", "usr");
jobj.put("Password", "passwd");
jobj.put("grant_type", "password");

final JsonObjectRequest jor = new JsonObjectRequest(

    Request.Method.POST, 
    api, jobj, 
    new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            Toast.makeText(getApplicationContext(), "Login Successful!", Toast.LENGTH_LONG).show();
            //do other things with the received JSONObject
        }
    }, 
    new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(getApplicationContext(), "Error!", Toast.LENGTH_LONG).show();
        }
    }) {

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String> pars = new HashMap<String, String>(); …
Run Code Online (Sandbox Code Playgroud)

android android-volley

38
推荐指数
3
解决办法
3万
查看次数

如何使用带有字体的凌空发送POST请求?

我正在开发一个与我编写的RESTful Web服务进行通信的Android应用程序.使用Volleyfor GET方法非常简单,但我不能指责POST方法.

我想在POST请求String正文中发送请求,并检索Web服务的原始响应(如200 ok,500 server error).

所有我能找到的是StringRequest不允许发送数据(正文),并且它限制我接收解析的String响应.我也遇到了JsonObjectRequest接受数据(正文)但检索解析后的JSONObject响应.

我决定编写自己的实现,但是我找不到从Web服务接收原始响应的方法.我该怎么做?

rest android web-services android-volley

38
推荐指数
3
解决办法
9万
查看次数

如何在Android中使用Volley库制作soap post请求

我想制作使用Volley库制作肥皂贴请求.我使用以下代码并得到错误"HTTP/1.1 400错误请求".在以前我使用Soap库工作正常,但我需要使用Volley库提出请求.我正在使用以下URL" http://test.com/TestApp/Services/service.asmx?op=ForgotPassword "

public void forgotPassword(final String userName,String url) {

        StringRequest sr = new StringRequest(Request.Method.POST,
                url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {

                        Toast.makeText(mContext, "Success" + response,
                                Toast.LENGTH_SHORT).show();
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        showResponse(error);
                    }
                }) {
            @Override
            protected Map<String, String> getParams() {
                Map<String, String> params = new HashMap<String, String>();

                params.put("Email", userName);
                params.put("Language", "en");


                return params;
            }

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> params = new HashMap<String, …
Run Code Online (Sandbox Code Playgroud)

android soap android-volley

15
推荐指数
1
解决办法
5236
查看次数

标签 统计

android ×3

android-volley ×3

rest ×1

soap ×1

web-services ×1