简体   繁体   English

java.io.IOException:CONNECT 的意外响应代码:400

[英]java.io.IOException: Unexpected response code for CONNECT: 400

I am using Okhttp client to get the OAuth 2.0 token based on a Rest API.我正在使用 Okhttp 客户端获取基于 Rest API 的 OAuth 2.0 令牌。

When I deploy it over Weblogic 12c its showing the error java.io.IOException: Unexpected response code for CONNECT: 400当我通过 Weblogic 12c 部署它时,它显示错误java.io.IOException: Unexpected response code for CONNECT: 400

I have tried to change the implementation and header method methods in different styles might be my request is failing because I am providing wrong credentials but nothing changed.我试图以不同的样式更改实现和标头方法方法,可能是我的请求失败了,因为我提供了错误的凭据,但没有任何改变。

Can anybody suggest what I am doing wrong in my code?有人可以建议我在代码中做错了什么吗?

Client Code客户代码

public String Post (String url, String json) throws IOException {

        Response response = null;
        try {

        logger.info("FMS WEBSERVICE LOG >>> Posting method...");

        RequestBody body = RequestBody.create(JSON, json);

        logger.info("FMS WEBSERVICE LOG >>> body: " + body);

        Request request = new Request.Builder().url(url).post(body).build();

        logger.info("FMS WEBSERVICE LOG >>> request: " + request);
        response = client.newCall(request).execute();

        logger.info("FMS WEBSERVICE LOG >>> returning: " + response.toString());

        }
        catch (Exception e) {
            logger.info("FMS WEBSERVICE LOG >>> exception in WebServiceClient: " + e);
        }

        return response.body().string();

    }

@GET
    @Path("/fundTransfer")
    @Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON)
    public String soapCaller() throws IOException, JSONException  {

        logger.info("FMS WEBSERVICE LOG >>> Inside the client method");

        String json = new StringBuilder()
                .append("{")
                .append("\"grant_type\":\"client_credentials\",")
                .append("\"client_id\":\"0146b9a4-7e99-4c83-8e9e-6049cfec55da\",")
                .append("\"client_secret\":\"nY3oL5xQ3bJ8yT3nC1nV5bY4mY6eW7yP1nY6dS6rQ2nE5iR0rM\",")
                .append("\"scope\":\"ABLApis\"")
                .append("}").toString();

        logger.info("FMS WEBSERVICE LOG >>> JSON >>> " + json.toString());

        String response = Post("https://221.120.211.69:443/abl-api/uat/oauth2/token", json);

        logger.info("FMS WEBSERVICE LOG >>> response >>> " + response);

        return response;

    }

I am using postman to hit the GET Request with this URL: http:///FMS_WEB_SERVICES/fmsServices/fundTransfer我正在使用邮递员通过以下 URL 发送 GET 请求:http:///FMS_WEB_SERVICES/fmsServices/fundTransfer

CONNECT is the HTTP method OkHttp uses to build an HTTPS connection through a proxy server. CONNECT是 OkHttp 用来通过代理服务器建立 HTTPS 连接的 HTTP 方法。 It uses either the proxy server configured in your OkHttpClient, or the one the JVM prefers via its ProxySelector feature.它使用 OkHttpClient 中配置的代理服务器,或者 JVM 通过其 ProxySelector 功能首选的代理服务器。

A 400 response from CONNECT implies the proxy doesn't like the CONNECT request.来自 CONNECT 的 400 响应意味着代理不喜欢 CONNECT 请求。 You probably need to disable the proxy altogether (pass Proxy.NO_PROXY to OkHttpClient.Builder) or fix it to accept this call.您可能需要完全禁用代理(将 Proxy.NO_PROXY 传递给 OkHttpClient.Builder)或修复它以接受此调用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.io.IOException:CONNECT的意外响应代码:405 - java.io.IOException: Unexpected response code for CONNECT: 405 java.io.IOException:HTTP响应代码:400用于URL - java.io.IOException: HTTP response code: 400 for URL 服务器返回URL的HTTP响应代码:400:java.io.IOException - Server returned HTTP response code: 400 for URL : java.io.IOException Spring 启动:返回 HTTP 响应代码 400,嵌套异常为 java.ZF98ED07A4D5F50F4F770Exception - Spring Boot: returned HTTP response code 400, nested exception is java.io.IOException 服务器返回 java.io.IOException:服务器返回 HTTP 响应代码:URL 为 400 - server returns java.io.IOException: Server returned HTTP response code: 400 for URL java.io.IOException:服务器返回HTTP响应代码:400表示URL - java.io.IOException: Server returned HTTP response code: 400 for URL 获取java.io.IOException:服务器返回的HTTP响应代码:URL为400,但可以在浏览器中正常访问 - Get an java.io.IOException: Server returned HTTP response code: 400 for URL but can access it fine in browser URLConnection错误 - java.io.IOException:服务器返回HTTP响应代码:URL为400 - URLConnection Error - java.io.IOException: Server returned HTTP response code: 400 for URL java.io.IOException:服务器为URL返回HTTP响应代码:400 - java.io.IOException: Server returned HTTP response code: 400 for URL: HttpURLConnection错误-java.io.IOException:服务器返回的HTTP响应代码:URL的400 - HttpURLConnection Error - java.io.IOException: Server returned HTTP response code: 400 for URL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM