3

他の人が作成した RestService のインターフェイスを使用して、安静なクライアントを作成する必要があります... 1つのことを除いて、それはうまくいきます...

rest-easy 2.3.5.Final から rest-easy 3.0.x に更新すると、ClientRequestFactory クラスが @Deprecated のように表示されます。

実際のコードは次のとおりです。

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

バージョン 3.0.x の ClientRequestFactory の安静の代替手段は何ですか?

4

1 に答える 1

6

JAX-RS が Client-API を標準化したため、Resteasy Client-API は非推奨とマークされました。新しい Client-API の Resteasy 統合に関する情報は、ドキュメントにあります。

あなたの例は(テストされていない)のようになります:

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

または、Resteasy Proxy Framework を使用する場合:

Client client = ClientFactory.newClient();
ResteasyWebTarget target = (ResteasyWebTarget) client.target("http://url-of-service");
SomeRestInterface client = target.proxy(SomeRestInterface.class);
client.theMethod();
于 2013-08-24T06:50:20.950 に答える