3

I need to create rest-easy client, using de interface of the RestService created by others... That's work good, except by just one thing...

When i update from rest-easy 2.3.5.Final to rest-easy 3.0.x, the ClientRequestFactory class appear like @Deprecated.

The actual code is:

ClientRequestFactory crf = new ClientRequestFactory(UriBuilder.fromUri("http://url-of-service").build());
SomeRestInterface client = crf.createProxy(SomeRestInterface.class);
client.theMethod();

Any one, now what is the alternative of rest-easy for ClientRequestFactory at version 3.0.x?

  • Possible duplicate of [What to use instead of org.jboss.resteasy.client.ClientRequest?](http://stackoverflow.com/questions/14458450/what-to-use-instead-of-org-jboss-resteasy-client-clientrequest) – Gregor Nov 25 '16 at 14:46

1 Answers1

5

Resteasy Client-API has been marked deprecated as JAX-RS standardized a Client-API. You can find information about the Resteasy-integration of the new Client-API in the documentation.

Your example could look like (untested):

Client client = ClientBuilder.newClient();
Response response = client.target("http://url-of-service").request().get();
// read and close the response

Or if you want to use Resteasy Proxy Framework:

Client client = ClientFactory.newClient();
ResteasyWebTarget target = (ResteasyWebTarget) client.target("http://url-of-service");
SomeRestInterface client = target.proxy(SomeRestInterface.class);
client.theMethod();
munyengm
  • 15,029
  • 4
  • 24
  • 34
lefloh
  • 10,653
  • 3
  • 28
  • 50
  • I need to do the same thing but I cannot find ClientFactory, so from which jar do you use ClientFactory? Thank you! :) – aurelius Jan 09 '15 at 08:41
  • Don't know if this class was renamed in between but it should be [ClientBuilder](https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/client/ClientBuilder.html) from the JAX-RS 2.0 API. Thanks for the hint, I updated the answer. – lefloh Jan 10 '15 at 15:43
  • What will be the replacement of below two lines in 3.0.x version? `ClientResponse> response = request.get(new GenericType>(){}); List students = response.getEntity();` –  Mar 30 '16 at 20:39
  • What does `request#get` return? – lefloh Mar 30 '16 at 20:53
  • There is no request object now. I want to use latest API's old is not relevant now. I update my query here: http://stackoverflow.com/questions/36319394/what-should-we-use-for-clientresponse-and-generictype-in-latest-version-3-0-x please guide –  Mar 30 '16 at 20:57