My requirement is to use Apache CXF Rest Client API vendor has provided an url http://test.com
Method: get
Url: /getDetails
Header set to application/json
and parameter z=12345
And Response as JSON:
{
"hasMore": "true",
"results": [
{
"name": "ATM: 16th & Treemont",
"phone": "(303) 249--‐9117",
"streetAddress": "303 16th St. Suite 100"
},
{
"name": "ATM2:17th & Fremont",
"phone": "(555) 999-98886",
"streetAddress": "304 17th St. Suite 200"
}
]
}
When I read the documentation for the Client API I see link: http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-CXFWebClientAPI WebClient approach: if i go by this example, it describes about Book() how do I describe Book object for my requirement?
WebClient client = WebClient.create("http://books");
client.path("bookstore/books");
client.type("text/xml").accept("text/xml")
Response r = client.post(new Book());
Book b = r.readEntity(Book.class);
Also I see usage of Proxy: It talks about BookStore.class ..wont this be the server object? if so I will not be able to create or have BookStore class or object at my end.
BookStore store = JAXRSClientFactory.create("http://bookstore.com", BookStore.class);
// (1) remote GET call to http://bookstore.com/bookstore
Books books = store.getAllBooks();
// (2) no remote call
BookResource subresource = store.getBookSubresource(1);
// {3} remote GET call to http://bookstore.com/bookstore/1
Book b = subresource.getBook();
Should I create a Object similar to Book() for my response? I actually have to read each value from the JSON response (jettison). Which approach should I follow for my reqruiement and how should I proceed. I am confused please advice.
My requirement is strict to use Apache CXF Rest API.