jersey-client

Jersey Client: Logging HTTP Redirects

微笑、不失礼 提交于 2021-02-08 08:51:14
问题 I'm using JAX-RS with Jersey. When sending a POST request to an API, I receive a 302 and Jersey follows automatically which results in a 403. In my logging, however, I can only see the failed responses: INFO Rest-Request: POST http://[Jenkins-IP]/job/RestTestingArea/job/testJob/doDelete INFO Rest-Response: POST 403 http://[Jenkins-IP]/job/RestTestingArea/job/testJob/doDelete I have determined that in between request and response there is a redirect because when I turn off redirects, the

Jersey Client: Logging HTTP Redirects

江枫思渺然 提交于 2021-02-08 08:51:11
问题 I'm using JAX-RS with Jersey. When sending a POST request to an API, I receive a 302 and Jersey follows automatically which results in a 403. In my logging, however, I can only see the failed responses: INFO Rest-Request: POST http://[Jenkins-IP]/job/RestTestingArea/job/testJob/doDelete INFO Rest-Response: POST 403 http://[Jenkins-IP]/job/RestTestingArea/job/testJob/doDelete I have determined that in between request and response there is a redirect because when I turn off redirects, the

“Already connected” Exception when running jersey application inside docker container

*爱你&永不变心* 提交于 2021-01-28 04:07:20
问题 I am trying to dockerize a jersey application which acts both as a REST server and client. The application seems to behave differently when running inside a docker container. I am able to perform a request to a non-dockerized service (A). The problem occurs when I try to perform a request on another non-dockerized REST server (B), using, in both cases, JAX-RS client API: // common code - for contacting both A & B services private static final Client client = ClientBuilder.newClient().register

How to implement a retry mechanism in jersey-client java

眉间皱痕 提交于 2020-12-05 08:45:13
问题 I am doing some http rest api calls using jersey-client. Now I want to do a retry for a failure request. Say if the return error code is not 200 then I want to retry it again for a few times. How can do it using Jersey client 回答1: For implementing retries in any situation, check out Failsafe: RetryPolicy retryPolicy = new RetryPolicy() .retryIf((ClientResponse response) -> response.getStatus() != 200) .withDelay(1, TimeUnit.SECONDS) .withMaxRetries(3); Failsafe.with(retryPolicy).get(() ->

Jersey 2 filter uses Container Request Context in Client Request Filter

喜夏-厌秋 提交于 2020-05-10 02:58:55
问题 I have a Jersey 2 Web Service that upon receiving a request, makes another request to another web service in order to form the response for the original request. So, when client "A" makes a request to my web service "B", "B" makes a request to "C" as part of forming the response to "A". A->B->C I want to implement a filter for a Jersey 2 web service that essentially does this: Client "A" will send a request that has a header like "My-Header:first" When my web service "B" then makes a client

Jersey 2 filter uses Container Request Context in Client Request Filter

匆匆过客 提交于 2020-05-10 02:53:40
问题 I have a Jersey 2 Web Service that upon receiving a request, makes another request to another web service in order to form the response for the original request. So, when client "A" makes a request to my web service "B", "B" makes a request to "C" as part of forming the response to "A". A->B->C I want to implement a filter for a Jersey 2 web service that essentially does this: Client "A" will send a request that has a header like "My-Header:first" When my web service "B" then makes a client

Jersey client throws javax.ws.rs.ProcessingException: java.net.ConnectException : failed to connect to /127.0.0.1 (port 8080)

徘徊边缘 提交于 2020-01-24 01:21:08
问题 I am working with an Android jersey client that sends a form to a web-service. I am getting javax.ws.rs.ProcessingException: java.net.ConnectException: failed to connect to /127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused) I don't have any proxies configured. I can use the web-service via Postman(browser shows it as well). The SO posts that I have seen till now all talk about having proxies or the server being inactive, both of which is untrue in my case. My android

Encoding curly braces in Jersey Client 2

ぃ、小莉子 提交于 2020-01-23 07:55:11
问题 We are using Jersey Client 2.21. I am noticing that when we put curly braces (aka curly brackets) as a param value, then it does not get properly encoded. Not only that, but anything inside the curly braces does not get encoded either. This is not true for regular brackets or other unsafe characters that I have tested with. Please see the example below. In this example I enter three params. A control param with just spaces. One with curly braces, and one with regular brackets. public static

Can jersey clients POST a JAXB object to the server using JSON?

点点圈 提交于 2020-01-14 06:32:34
问题 I'm finding a lot of examples of how to set up a jersey server so that it can produce and consume JAXB bound objects but I'm having trouble finding examples of how to get the client to post the same JAXB bound object. This example shows how to do it with XML. I'm looking for one that shows how to do it with JSON. I'm not even sure if this is possible to do. The javadoc on the post method(s) are ambiguous. My post looks like this: Client client = Client.create(); WebResource resource = client