Web services 无法使用httpClient身份验证和post登录到web服务

Web services 无法使用httpClient身份验证和post登录到web服务,web-services,httpclient,Web Services,Httpclient,我正在使用httpClient 4向axelor进行身份验证,并尝试调用web服务 登录URL是,我正在使用docker在一个单独的容器中部署axelor 首先,我将发布到登录URL,响应cookies将被存储,并将在后续请求中使用。这就是我使用的策略。下面给出了相同的代码 public String callService(String jsonString, String endPoint) throws Exception{ String LOGIN_URL="http:/

我正在使用httpClient 4向axelor进行身份验证,并尝试调用web服务

登录URL是,我正在使用docker在一个单独的容器中部署axelor

首先,我将发布到登录URL,响应cookies将被存储,并将在后续请求中使用。这就是我使用的策略。下面给出了相同的代码

public String callService(String jsonString, String endPoint) throws Exception{
        String LOGIN_URL="http://localhost:8082/login.jsp";
        String SECURED_URL="http://localhost:8082/ws/meta/models";
        CredentialsProvider provider = new BasicCredentialsProvider();
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("akhil", "akhil*123");
        provider.setCredentials(AuthScope.ANY, credentials);
        HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();

        CookieStore cookieStore = new BasicCookieStore(); 
        HttpClientContext httpContext = HttpClientContext.create();
        httpContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
        HttpPost httpPost = new HttpPost(LOGIN_URL);

        HttpResponse response = client.execute(httpPost,httpContext);
        int statusCode = response.getStatusLine().getStatusCode();
        if(statusCode == HttpStatus.SC_OK) {
            HttpResponse response2 = client.execute(new HttpGet(SECURED_URL),httpContext);
            System.out.println(response2.getStatusLine().getStatusCode());
            System.out.println(EntityUtils.toString(response2.getEntity()));
        }else {

        }
        return "";
    }
这将在第一次登录时返回状态代码为200,但在下一个HttpGet请求中,它将被重定向到登录页面

我做错了什么

axelor文档要求您按以下方式登录:

同样,postman应用程序也可以很好地工作,但我不知道为什么它不能在java中与httpClient一起工作

toString(response2.getEntity())将打印登录页面

但预期结果是模型的json,如下所示:

{
    "status": 0,
    "total": 480,
    "data": [
        "com.axelor.apps.account.db.Account",
        "com.axelor.apps.account.db.AccountChart",
        "com.axelor.apps.account.db.AccountClearance",
        "com.axelor.apps.account.db.AccountConfig",
        "com.axelor.apps.account.db.AccountEquiv",
.
.
.
我将与此帖子共享日志文件以供参考:

2019-03-27 12:44:23.157 DEBUG 19732 --- [nio-8084-exec-3] o.a.h.client.protocol.RequestAddCookies  : CookieSpec selected: default
2019-03-27 12:44:23.157 DEBUG 19732 --- [nio-8084-exec-3] o.a.h.client.protocol.RequestAddCookies  : Cookie [version: 0][name: JSESSIONID][value: 9D09E72B8A1EB0890BB75739D92795EF][domain: localhost][path: /][expiry: null] match [localhost:8082/ws/meta/models]
2019-03-27 12:44:23.157 DEBUG 19732 --- [nio-8084-exec-3] o.a.h.client.protocol.RequestAuthCache   : Auth cache not set in the context
2019-03-27 12:44:23.157 DEBUG 19732 --- [nio-8084-exec-3] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {}->http://localhost:8082][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2019-03-27 12:44:23.157 DEBUG 19732 --- [nio-8084-exec-3] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 3][route: {}->http://localhost:8082][total kept alive: 0; route allocated: 2 of 2; total allocated: 2 of 20]
2019-03-27 12:44:23.157 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Opening connection {}->http://localhost:8082
2019-03-27 12:44:23.158 DEBUG 19732 --- [nio-8084-exec-3] .i.c.DefaultHttpClientConnectionOperator : Connecting to localhost/127.0.0.1:8082
2019-03-27 12:44:23.158 DEBUG 19732 --- [nio-8084-exec-3] .i.c.DefaultHttpClientConnectionOperator : Connection established 127.0.0.1:50304<->127.0.0.1:8082
2019-03-27 12:44:23.158 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Executing request GET /ws/meta/models HTTP/1.1
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Target auth state: UNCHALLENGED
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Proxy auth state: UNCHALLENGED
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> GET /ws/meta/models HTTP/1.1
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> Host: localhost:8082
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> Connection: Keep-Alive
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> User-Agent: Apache-HttpClient/4.5.7 (Java/1.8.0_201)
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> Cookie: JSESSIONID=9D09E72B8A1EB0890BB75739D92795EF
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> Accept-Encoding: gzip,deflate
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "GET /ws/meta/models HTTP/1.1[\r][\n]"
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "Host: localhost:8082[\r][\n]"
2019-03-27 12:44:23.159 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "Connection: Keep-Alive[\r][\n]"
2019-03-27 12:44:23.160 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "User-Agent: Apache-HttpClient/4.5.7 (Java/1.8.0_201)[\r][\n]"
2019-03-27 12:44:23.160 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "Cookie: JSESSIONID=9D09E72B8A1EB0890BB75739D92795EF[\r][\n]"
2019-03-27 12:44:23.160 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2019-03-27 12:44:23.160 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "[\r][\n]"
2019-03-27 12:44:23.162 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "HTTP/1.1 302 [\r][\n]"
2019-03-27 12:44:23.163 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Server: nginx/1.15.9[\r][\n]"
2019-03-27 12:44:23.163 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Date: Wed, 27 Mar 2019 07:14:23 GMT[\r][\n]"
2019-03-27 12:44:23.163 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Content-Length: 0[\r][\n]"
2019-03-27 12:44:23.164 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Connection: keep-alive[\r][\n]"
2019-03-27 12:44:23.164 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Location: /login.jsp[\r][\n]"
2019-03-27 12:44:23.165 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "[\r][\n]"
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << HTTP/1.1 302 
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Server: nginx/1.15.9
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Date: Wed, 27 Mar 2019 07:14:23 GMT
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Content-Length: 0
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Connection: keep-alive
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Location: /login.jsp
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Connection can be kept alive indefinitely
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] h.i.c.PoolingHttpClientConnectionManager : Connection [id: 3][route: {}->http://localhost:8082] can be kept alive indefinitely
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-3: set socket timeout to 0
2019-03-27 12:44:23.166 DEBUG 19732 --- [nio-8084-exec-3] h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: 3][route: {}->http://localhost:8082][total kept alive: 1; route allocated: 2 of 2; total allocated: 2 of 20]
2019-03-27 12:44:23.167 DEBUG 19732 --- [nio-8084-exec-3] o.a.h.i.client.DefaultRedirectStrategy   : Redirect requested to location '/login.jsp'
2019-03-27 12:44:23.167 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.RedirectExec     : Redirecting to 'http://localhost:8082/login.jsp' via {}->http://localhost:8082
2019-03-27 12:44:23.167 DEBUG 19732 --- [nio-8084-exec-3] o.a.h.client.protocol.RequestAddCookies  : CookieSpec selected: default
2019-03-27 12:44:23.167 DEBUG 19732 --- [nio-8084-exec-3] o.a.h.client.protocol.RequestAddCookies  : Cookie [version: 0][name: JSESSIONID][value: 9D09E72B8A1EB0890BB75739D92795EF][domain: localhost][path: /][expiry: null] match [localhost:8082/login.jsp]
2019-03-27 12:44:23.167 DEBUG 19732 --- [nio-8084-exec-3] o.a.h.client.protocol.RequestAuthCache   : Auth cache not set in the context
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {}->http://localhost:8082][total kept alive: 1; route allocated: 2 of 2; total allocated: 2 of 20]
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 3][route: {}->http://localhost:8082][total kept alive: 0; route allocated: 2 of 2; total allocated: 2 of 20]
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-3: set socket timeout to 0
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Executing request GET /login.jsp HTTP/1.1
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Target auth state: UNCHALLENGED
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Proxy auth state: UNCHALLENGED
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> GET /login.jsp HTTP/1.1
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> Host: localhost:8082
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> Connection: Keep-Alive
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> User-Agent: Apache-HttpClient/4.5.7 (Java/1.8.0_201)
2019-03-27 12:44:23.168 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> Cookie: JSESSIONID=9D09E72B8A1EB0890BB75739D92795EF
2019-03-27 12:44:23.169 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 >> Accept-Encoding: gzip,deflate
2019-03-27 12:44:23.169 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "GET /login.jsp HTTP/1.1[\r][\n]"
2019-03-27 12:44:23.169 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "Host: localhost:8082[\r][\n]"
2019-03-27 12:44:23.169 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "Connection: Keep-Alive[\r][\n]"
2019-03-27 12:44:23.169 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "User-Agent: Apache-HttpClient/4.5.7 (Java/1.8.0_201)[\r][\n]"
2019-03-27 12:44:23.169 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "Cookie: JSESSIONID=9D09E72B8A1EB0890BB75739D92795EF[\r][\n]"
2019-03-27 12:44:23.169 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2019-03-27 12:44:23.169 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 >> "[\r][\n]"
2019-03-27 12:44:23.175 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "HTTP/1.1 200 [\r][\n]"
2019-03-27 12:44:23.175 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Server: nginx/1.15.9[\r][\n]"
2019-03-27 12:44:23.175 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Date: Wed, 27 Mar 2019 07:14:23 GMT[\r][\n]"
2019-03-27 12:44:23.175 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Content-Type: text/html;charset=UTF-8[\r][\n]"
2019-03-27 12:44:23.176 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Transfer-Encoding: chunked[\r][\n]"
2019-03-27 12:44:23.176 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Connection: keep-alive[\r][\n]"
2019-03-27 12:44:23.176 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Vary: Accept-Encoding[\r][\n]"
2019-03-27 12:44:23.177 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "Content-Encoding: gzip[\r][\n]"
2019-03-27 12:44:23.178 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "[\r][\n]"
2019-03-27 12:44:23.178 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "413[\r][\n]"
2019-03-27 12:44:23.178 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x3][0xac]Vmo[0xdb]6[0x10][0xfe][0x9c][0xfc][0x8a][0xb]W[0xe4][0x5][0xa8][0xac][0xa4][0xe8][0x80]u[0x95][0xc][0x4]Y[0xb][0x14][0xd8][0xd0] m?[0xec]#%[0x9e],6[0x14])[0x90][0x94][0x1d]o[0xed][0xdf]Q[0x94],[0xd9]IV[0xc][0x98][0x1][$u[0xc7][0xbb][0xe7][0xee][0xb9];g'[0xbf]}[0xbc][0xf9][0xfc][0xe7][0xed];[0xa8]}[0xa3][0x96][0xc7]Y|[0x0]d5r[0xb1]<[0x6][0xfa]d[\r]z[0xe]e[0xcd][0xad]C[0x9f][0xb3][0xce]W[0xc9]/l[0xfe]J[0xf3][0x6]s[0xb6][0x96][0xb8]i[0x8d][0xf5][0xc]J[0xa3]=j[0x12][0xdd]H[0xe1][0xeb]\[0xe0]Z[0x96][0x98][0xf4][0x9b][0x97] [0xb5][0xf4][0x92][0xab][0xc4][0x95]\a~[0xb5][0xb8]|[0x9][\r][0x90]M[0xd7][0xcc][0x8f]:[0x87][0xb6][0xdf][0xf3][0x82][0xa4][0xb4]y[0xc2][0xde][0xca][0x98][0x95][0xc2][0x99]5m[0xbc][0xe5][0xda])[0xee]q[0x14]WR[0xdf][0x83]E[0x95]3W[0x93]ke[0xe7]A[0x92]w[0xc]j[0x8b]U[0xce]h[0x9d]V[0x9c][0xbc]3zA?{ZQBH[0xe7]S[0xde][0xb6]J[0x96][0xdc]K[0x12]Sf%[0xf5]b[0xf5][0x97]l[0x17][0xa5]sl[0xb8][0xdc]o[0x15][0xba][0x1a][0xd1][0xd3][0x15][0x99]+[0xad]l=8[[0xe6][0xec][0xdf][0xf4][0xbf]:[0xb6][0xcc][0xd2](Mj[0xe9][0x18][0xf1][0xac]0b[0xbb]<[0x8e][0xb1][0x17]r[\r][0xa5][0xe2][0xce][0xe5],[0x84][0x95]KM[0x81][0xa9]T'[0xc5][0xe0]-[0xe5]g&[0xd3]r[0x8d][\n]"
2019-03-27 12:44:23.178 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "z'[0x93]~[0xbd][0x93]zB.[0x9][0x16][0xd1]B/[0x98][0x8][0xac]x[0xa7][0x2][0x82][0x90][0xf4][0xf8][0xc9]d[0xb3][0x8a]@h[0x91][0xf2][0x7]T[0xc6].Z[0xbd]b[0x10]S[0xcb][0xae][0xde][0xbc]j[0x1f]f*YJ[0xce]L7<r-[0x9][0xd8]f[0xf2][0xe4]Uel[0x3]R[0xe4],z[0x1d][0xb6][0xc]x[0x19][0xa2][0x9d]3[0x6]D[0xbe][0xda][0xd0][0xdb][0xdb][0x8f][0x9f]>[0xef])[0xee][0x3][\n]"
2019-03-27 12:44:23.178 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "jI%Q[0x9][0x8a][0xea][0xc]A[0xc0]1[0xf7]B[0xea][0xb6][0xf3]Ik[0xb1]E=[0x85]p[0x80][0x1b]d[0x1d]Ec[0x8c]8[0x17]"![0xb6],39[0x9e]T[0x1c]*[0x9e][0xa0]^S$Z[0xa2]Y[0x96][0xca][0x90]C[0xd2]94JW[0xf5][0xb6][0xc0]o[[0xaa][0xe][0x8f][0xf]T[0x19][0x1]f[0xa0]v[0xa8][0x98][0xf][0x82]A[0xac][0x9c][0xf1][0x84]A[0xab]x[0x89][0xb5]Q[0x94][0x95][0x9c]}[0x19][0x4])[0x1a][0x9d]7[0x95]);"[0xc1]n[0xf9][0x18][0xe5]~[0xe8]#[0xa4][0xff][0x1d][0xba]2[0xe5][0xfd][0x80][0xdd][0x12]s7[0xc6][0x12][0xd4][0x0]}[0xdc]M[0xd0][0xc7][0x93][0x3][0xe8][0xb7][0xa3][0xda]aT[0xf][0xf8]5[0x80]T[0xbc] [0xd6][0xf]e"[0xb]3g[0xe4][0x98][0xda][0xbd]l[0x94]5[0x96][0xf7]A[0xe][0xd6]\u[0x94][0x1e][0x8b][\r]6[0x5][0xda]?[0xa8][0xa1][0xc4][0xa4][0xcc]N[0xe][0x9d]8`Io[0xef]Y[0x12][0xcc][0xf9][0xe4][0xa5][0xa7][0x8e][0xb5][0xbc][0x1b][0x8c][0x11][0xb7][0x9f]V[0xcb][0xd2][0x1e][0xd1][0xbe][0xdd]'[0xa0][0xcf][0xb3][0x1b][0xb][0xc0][0x18][0x8f][0xf6]15[0x8a][0xce]{[0xb3][0xa3]u[0xe1]5[0xd0][0x97][0xaa]@6[0xdc]n[0xd9]@Q[0xd7][0x15][0x8d][0xa4][0xfa][0xff][0xdd][0xac][0xa8]KgiT[0xfa][0x81][0x13]Y[0x1a][0xc]OB{^[0xee]oB[0x9b][\n]"
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << ",(l[0xb2][0xe1]V[0xcb][0xd0]F[0x86][0x9c][0xd1]([0xb0][0x1e][0xfa][0xdf][0xa4][0x8][0x14][0x1b][0xd6]h[0xad][0xb1]PK![0x90][0xca][0xf0][0xf8][0x8][0xe0]([0xab]_/[0xbf][0xb4][0x82][0x9a]<lMg[0xa1][0xb0]fC[0x85]rB[0xfd][0xf3][0xf5] [0xd1][0xd1] [0xb][0xa2]G[0x99][0x92][0xcb][0x9b][0xda][0x9a][0x10]gZN[0x87][0xef]%[0xf5][0xf3]pp[0xfa][0x89]W[0xdc][0xca][0x83][0xc3][0xf][0xef]`[0x99][0xc3][0xd5][0xd5]t[0x9c][0xa5][0x83][0x81][0x1][0x1e][0x99][0xea][0x13][0x11][0xb0]q[0xf1][0xc][0xb6]G[0x18][0xae]E[0xf][0x94][0xda][0xaf]@[0x8f][0xa5]G1[0x83]p[0xab][0x90];[0x4][0x9a][0x1e]a[0xfe][0x81][0xaf][0x11][0xf8]N[0x9e];[0x90][0x9e][0x86][0xe6][0x16][0x9c]2[0x1b][0x10]f[0xa3][0xa3][0xc4]lL[0xcd]"?,[0xe3]8[0xa9]z[0x82][0x8c]av[0xa2][0xb4];[0x9][0x8b][0x82][0x8c][0xb9][0x86]+[0xc5][0x96][0xa7][0xa5]i[0xb7]o[0xe1][0xd5][0xe5][0xe5][0xcf][0x90][0xd0][0xe3][0xea][\r]\[0xc7][0x99][0x0][0xd7]J[0xc1][0x9d]\[0xd5][0xde][0xc1][0x1d]R>[0xd6]([0x16]Y[0xda]Fb[0x4][0x92][0x4]b[0xc6][0xdd]4[0xd8]b[0xc4][0xfa]8[0x84][0x9e][0xd2][0x8f][0x8e][0xf8]v[0x98][0xa1]S[0xef]L[0xbf][0xf2]5[0x8f][0xa7][0x3][0xbd]_[0x9c]W[0x9d][0xee][0xc7][0x4][0x9c]_[0xc0][0xdf]![0xb9][0x0][0xb2][0x82][0xf3]aL[\r][0xc4]X4N"[0x9c][0x9e][0xc2][0xc9][0xc1][0xb9]][0xef][0xb4][0x8e]^[0x9c][0x9f][0xfd]4[0xd1][0xf2][0xec]bA[0xd5]o[0xd6]x[0x13][0x6][0xef][0xf9]Y[0xcc][0xdd][0xd9][0xc5][0xdb]h[0xe3][0xfb]d*[0xe8][\r][0x89]9[0xbb][0x80]<[0xcf][0xa1][0xd3]4GiH[0xb][0xf8][0xf6][\r][0xf6]^/$][0xf5][0xeb]x[0xd7][0xbe][0xed][0x89]6?[0xb4][0x1d]P~'W[0xc2]s[0xfa][0xf7][0x10][0xd6][0xf1]o[0x3][0xd5]A[0xff]O[0xee][0x1f][0x0][0x0][0x0][0xff][0xff][\r][\n]"
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "a[\r][\n]"
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "[0x3][0x0][0x13]7[0xbc]S[0xda][0x9][0x0][0x0][\r][\n]"
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "0[\r][\n]"
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.wire                     : http-outgoing-3 << "[\r][\n]"
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << HTTP/1.1 200 
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Server: nginx/1.15.9
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Date: Wed, 27 Mar 2019 07:14:23 GMT
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Content-Type: text/html;charset=UTF-8
2019-03-27 12:44:23.179 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Transfer-Encoding: chunked
2019-03-27 12:44:23.180 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Connection: keep-alive
2019-03-27 12:44:23.180 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Vary: Accept-Encoding
2019-03-27 12:44:23.180 DEBUG 19732 --- [nio-8084-exec-3] org.apache.http.headers                  : http-outgoing-3 << Content-Encoding: gzip
2019-03-27 12:44:23.180 DEBUG 19732 --- [nio-8084-exec-3] o.a.http.impl.execchain.MainClientExec   : Connection can be kept alive indefinitely

2019-03-27 12:44:23.157调试19732---[nio-8084-exec-3]o.a.h.client.protocol.RequestAddCookies:CookieSpec selected:default
2019-03-27 12:44:23.157调试19732---[nio-8084-exec-3]o.a.h.client.protocol.RequestAddCookies:Cookie[version:0][name:JSESSIONID][value:9D09E72B8A1EB0890BB75739D92795EF][domain:localhost][path://][expiration:null]匹配[localhost:8082/ws/meta models]
2019-03-27 12:44:23.157调试19732---[nio-8084-exec-3]o.a.h.client.protocol.RequestAuthCache:未在上下文中设置验证缓存
2019-03-27 12:44:23.157调试19732---[nio-8084-exec-3]h.i.c.PoollightTPClientConnectionManager:连接请求:[路由:{}->http://localhost:8082][保持活动状态的总数:0;分配的路由:1/2;分配的总数:1/20]
2019-03-27 12:44:23.157调试19732---[nio-8084-exec-3]h.i.c.PoollightTPClientConnectionManager:已租用的连接:[id:3][路由:{}->http://localhost:8082][保持活动状态的总数:0;分配的路由:2/2;分配的总数:2/20]
2019-03-27 12:44:23.157调试19732---[nio-8084-exec-3]o.a.http.impl.execchain.MainClientExec:打开连接{}->http://localhost:8082
2019-03-27 12:44:23.158调试19732---[nio-8084-exec-3].i.c.DefaultHttpClientConnectionOperator:连接到本地主机/127.0.0.1:8082
2019-03-27 12:44:23.158调试19732---[nio-8084-exec-3].i.c.DefaultHttpClientConnectionOperator:连接已建立127.0.0.1:50304127.0.0.1:8082
2019-03-27 12:44:23.158调试19732---[nio-8084-exec-3]o.a.http.impl.execchain.MainClientExec:执行请求GET/ws/meta/models http/1.1
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]o.a.http.impl.execchain.MainClientExec:目标身份验证状态:未被质疑
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]o.a.http.impl.execchain.MainClientExec:代理身份验证状态:未被质疑
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.headers:http-outgoing-3>>GET/ws/meta/models http/1.1
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.headers:http-outing-3>>主机:localhost:8082
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.headers:http-outing-3>>连接:保持活动状态
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.headers:http-outing-3>>用户代理:apache HttpClient/4.5.7(Java/1.8.0201)
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.headers:http-outgoing-3>>Cookie:JSESSIONID=9D09E72B8A1EB0890BB75739D92795EF
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.headers:http-outgoing-3>>接受编码:gzip,deflate
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outgoing-3>>“GET/ws/meta/models http/1.1[\r][\n]”
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outing-3>>“主机:本地主机:8082[\r][\n]”
2019-03-27 12:44:23.159调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outgoing-3>>“连接:保持活动[\r][\n]”
2019-03-27 12:44:23.160调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outing-3>>“用户代理:apache HttpClient/4.5.7(Java/1.8.0_201)[\r][\n]”
2019-03-27 12:44:23.160调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outgoing-3>>“Cookie:JSESSIONID=9D09E72B8A1EB0890BB75739D92795EF[\r][\n]”
2019-03-27 12:44:23.160调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outgoing-3>>“接受编码:gzip,deflate[\r][\n]”
2019-03-27 12:44:23.160调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outing-3>>“[\r][\n]”
2019-03-27 12:44:23.162调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outing-3用户代理:apache HttpClient/4.5.7(Java/1.8.0_201)
2019-03-27 12:44:23.168调试19732---[nio-8084-exec-3]org.apache.http.headers:http-outgoing-3>>Cookie:JSESSIONID=9D09E72B8A1EB0890BB75739D92795EF
2019-03-27 12:44:23.169调试19732---[nio-8084-exec-3]org.apache.http.headers:http-outgoing-3>>接受编码:gzip,deflate
2019-03-27 12:44:23.169调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outing-3>>“GET/login.jsp http/1.1[\r][\n]”
2019-03-27 12:44:23.169调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outing-3>>“主机:本地主机:8082[\r][\n]”
2019-03-27 12:44:23.169调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outing-3>>“连接:保持活动[\r][\n]”
2019-03-27 12:44:23.169调试19732---[nio-8084-exec-3]org.apache.http.wire:http-outing-3>>“使用
public String callService(String jsonString, String endPoint) throws Exception{
        String LOGIN_URL="http://localhost:8082/login.jsp";
        String SECURED_URL="http://localhost:8082/ws/meta/models";
        HttpClient httpClient = HttpClientBuilder.create().build(); //Use this instead 

        try {

            HttpPost httpPost = new HttpPost(LOGIN_URL);
            StringEntity params =new StringEntity("{\"username\":\"admin\",\"password\":\"admin\"} ");
            httpPost.addHeader("content-type", "application/json");
            httpPost.setEntity(params);
            HttpResponse response = httpClient.execute(httpPost);

            HttpGet httpGet = new HttpGet(SECURED_URL);
            HttpResponse response2 = httpClient.execute(httpGet);
            System.out.println(response2.getStatusLine().getStatusCode());
            System.out.println(EntityUtils.toString(response2.getEntity()));
        }catch (Exception ex) {

            //handle exception here

        } finally {
            //Deprecated
            //httpClient.getConnectionManager().shutdown(); 
        }   
        return "";
    }