I am using apache cxf webclient to consume a service written in .NET
sample JSON to be sent in request body to a web service
{
"Conditions":
[
{
"Field":"TextBody",
"Comparer":"ContainsAny",
"Values":["stocks","retire"],
"Proximity":0
},
{
"Field":"SentAt",
"Comparer":"LessThan",
"Values":["1331769600"],
"Proximity":0
},
],
"Operator":"And",
"ExpireResultIn":3600
}
Is there any way if I want to submit data from both form and in Json body in one request ? webclient API apache CXF -
web client API doc
WebClient client = WebClient.create("http://mylocalhost.com:8989/CXFTest/cxfws/rest/restservice/json");
client.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);
After this which method and how to use ?
client.form(...form object )
client.post(...JSON string )
They have not shared Object of "Conditions" in JSON which I can annotate and pass to post method of client
I got answer here Need to set JSON provider in my case it was jackson
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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With