0

こんにちは、volley ライブラリを使用して API 呼び出しを再構築しています

これは、XML データを送信し、xml 応答を受信するためのテスト コードです (文字列形式で応答を正常に受信する必要があるだけです)。

String url ="https://prdesb1.singpost.com/ma/FilterOverseasPostalInfo";
        final String payload = "<OverseasPostalInfoDetailsRequest xmlns=\"http://singpost.com/paw/ns\"><Country>AFAFG</Country><Weight>100</Weight><DeliveryServiceName></DeliveryServiceName><ItemType></ItemType><PriceRange>999</PriceRange><DeliveryTimeRange>999</DeliveryTimeRange></OverseasPostalInfoDetailsRequest>\n";

        RequestQueue mRequestQueue;

// Instantiate the cache
        Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap

// Set up the network to use HttpURLConnection as the HTTP client.
        Network network = new BasicNetwork(new HurlStack());

// Instantiate the RequestQueue with the cache and network.
        mRequestQueue = new RequestQueue(cache, network);

// Start the queue
        mRequestQueue.start();

// Formulate the request and handle the response.
        StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        // Do something with the response
                        Log.v("tesResponse","testResponseS");
                        Log.v("response",response);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        // Handle error
                        Log.v("tesResponse","testResponseF");
                        Log.v("error",error.toString());
                    }
                }
        ){
            @Override
            public String getBodyContentType() {
                return "application/xml; charset=" +
                        getParamsEncoding();
            }

            @Override
            public byte[] getBody() throws AuthFailureError {

                String postData = payload;
                try {
                    return postData == null ? null :
                            postData.getBytes(getParamsEncoding());
                } catch (UnsupportedEncodingException uee) {
                    // TODO consider if some other action should be taken
                    return null;
                }
            }
        };
//        stringRequest.setRetryPolicy(new DefaultRetryPolicy(5*DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, 0, 0));
        stringRequest.setRetryPolicy(new DefaultRetryPolicy(0, 0, 0));

// Add the request to the RequestQueue.
        mRequestQueue.add(stringRequest);

Stringurlpayloadon POSTMAN をテストしたところ、成功した結果が得られました。しかし、私のAndroidアプリでこのエラーが発生する理由がわかりません

08-22 19:44:24.335 16319-16518/com.example.victory1908.test1 D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true

                                                                               [ 08-22 19:44:24.355 16319:16319 D/         ]
                                                                               HostConnection::get() New Host Connection established 0x7f67de64eac0, tid 16319


                                                                               [ 08-22 19:44:24.399 16319:16518 D/         ]
                                                                               HostConnection::get() New Host Connection established 0x7f67de64edc0, tid 16518
08-22 19:44:24.410 16319-16518/com.example.victory1908.test1 I/OpenGLRenderer: Initialized EGL, version 1.4
08-22 19:44:24.662 16319-16319/com.example.victory1908.test1 V/tesResponse: testResponseF
08-22 19:44:24.662 16319-16319/com.example.victory1908.test1 V/error: com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Handshake failed

API 23+ (Android 6.0 以降) のみの問題に注意してください。API 22 は正常に動作しています!

再試行ポリシーを設定しようとしましたが、機能しません。コードの何が問題なのか誰でも知っています。前もって感謝します

4

0 に答える 0