4

我试图弄清楚如何使用 Jesrey Client 通过 Java 程序从客户端调用/调用服务提供的 PATCH 方法。

我尝试了很多方法,并在网上阅读了很多东西。但是,球衣似乎还不支持这一点。任何帮助将不胜感激。

我尝试过的示例代码之一。

    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getProperties().put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, true);
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);       
    clientConfig.getClasses().add(ProtobufMessageBodyReaderWriter.class);       
    CLIENT = Client.create(clientConfig);
           CLIENT.resource(BASE_URL);
    webResource = CLIENT.resource(BASE_URL);    
    T response = null;
    ClientResponse cResponse = null;
    cResponse = webResource.type(MediaType.APPLICATION_JSON).method("PATCH",ClientResponse.class, requestObject);

这给出了 "java.net.ProtocolException: HTTP method PATCH doesn't support output" 。任何人都可以建议我如何通过上述方式或任何其他方式完成这项工作

4

1 回答 1

0

从泽西的论坛上快速阅读,似乎有一个错误。

您可以使用 HTTP 客户端代替webResource.type(...).method("PATCH")吗?例如,使用 Apache HTTP Commons。

于 2013-10-08T08:31:51.153 回答