Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void helloAuth() {
- WebTarget wt = wsClient.target(AUTHORIZE_URL).queryParam("login", "soso").queryParam("password", "password");
- Invocation webServiceCall = wt.request()
- .accept("application/json")
- .build("POST");
- Response response = webServiceCall.invoke();
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- System.out.println("Authorized");
- response.close();
- wt = wsClient.target(HELLO_AUTHORIZE_URL);
- webServiceCall = wt.request()
- .accept("application/json")
- .build("GET");
- response = webServiceCall.invoke();
- if (response.getStatus() == Response.Status.OK.getStatusCode()) {
- System.out.println("Authorized resource accessed");
- } else {
- System.out.println("Authorized resource not accessed");
- }
- } else {
- System.out.println("Bad request");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement