如何在请求体中发送JSON数据起诉apache CXF webclient?

Nee*_*lpe 5 java web-services

我使用apache cxf webclient来使用用.NET编写的服务

示例JSON将在请求正文中发送到Web服务

{
   "Conditions":
      [
         {
            "Field":"TextBody",
            "Comparer":"ContainsAny",
            "Values":["stocks","retire"],
            "Proximity":0
         },
         {
            "Field":"SentAt",
            "Comparer":"LessThan",
            "Values":["1331769600"],
            "Proximity":0
         },
      ],
   "Operator":"And",
   "ExpireResultIn":3600
}
Run Code Online (Sandbox Code Playgroud)

如果我想在一个请求中从表单和Json正文中提交数据,有什么办法吗?webclient API apache CXF -

Web客户端API文档

WebClient client = WebClient.create("http://mylocalhost.com:8989/CXFTest/cxfws/rest/restservice/json");
 client.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);
Run Code Online (Sandbox Code Playgroud)

这个方法以后怎么用?

client.form(...form object )

client.post(...JSON string ) 
Run Code Online (Sandbox Code Playgroud)

他们没有在JSON中共享"条件"对象,我可以对其进行注释并传递给客户端的post方法

Nee*_*lpe 4

我在这里得到答案需要设置 JSON 提供程序在我的情况下它是杰克逊

List<Object> providers = new ArrayList<Object>();
providers.add( new JacksonJaxbJsonProvider() );

WebClient client = WebClient.create("http://localhost:8080/poc_restapi_cxf/api", 
                                     providers);
client = client.accept("application/json")
               .type("application/json")
               .path("/order")
               .query("id", "1");

 Order order = client.get(Order.class);
 System.out.println("Order:" + order.getCustomerName());
Run Code Online (Sandbox Code Playgroud)