Hi,

I'm currently wondering of what would be the best (CXF) way to handle a
response URL that I get, after saving a new resource.

In REST it is best practice to return Status Code 201 and a URL pointing to
the new resource after a POST request containing any kind of resource that
should be stored. My service I working well using JAX-RS annotations and CXF
as a Webservice-Stack. Now I would like to test my service. Therefore I
create a new resource receive the URL for this new resource back and would
like to GET this resource for purposes of unit testing.
Here is what I did:


Response response = roleService.create(roleTO, null);

assertNotNull(response);
assertEquals(org.apache.http.HttpStatus.SC_CREATED, response.getStatus());

Client client = WebClient.client(roleService);
WebClient webClient = WebClient.fromClient(client);
int offset = webClient.getBaseURI().toString().length();
webClient.replacePath(response.getLocation().toString().substring(offset));
RoleTO actual = webClient.get(RoleTO.class);


This code does not look nice to me. Since this should be a common usecase,
I'm wondering if there is a better way to do this? 
I would like to reuse the configuration of my proxy object, to reuse my
provider and authentication configuration.

Best regards
Jan



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Best-way-to-handle-JAX-RS-Creat-Resource-URLs-tp5718738.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to