Hi, my override of Resource.post() I setup the response much like the examples
in the documentation. Unfortunately, on the client side I am not getting same
information in my Response object. I am using Restlet 1.0.8 that comes with
the Mule Restlet Transport.
The relevant code from my post() method in my extensions of Resource:
@Override
public void post(Representation entity) {
// ...
// the entity has been persisted...
// ...
getResponse().setStatus(Status.SUCCESS_CREATED);
Representation representation = new StringRepresentation(mapText,
MediaType.TEXT_XML);
representation.setIdentifier(getRequest().getResourceRef().getIdentifier() +
"/" + map.getId());
getResponse().setEntity(representation);
if (logger.isDebugEnabled()) {
logger.debug("Response object created.");
logger.debug("Status: " + getResponse().getStatus());
logger.debug("Identifier: " +
getResponse().getEntity().getIdentifier());
}
}
On the client side (Groovy but I get the same results in Java):
Representation representation = new StringRepresentation(mapText,
MediaType.TEXT_XML)
Response response = client.post(uri, representation)
println "Status: " + response.getStatus()
println "Successful: " + response.getStatus().isSuccess()
println "Identifier: " + response.getEntity().getIdentifier()
I always get the following output from the client. OK is always the status
regardless of what I set as the code in my post() method. The Resource does
get posted/persisted during the request.
Response received.
Status: OK (200)
Successful: true
And a null pointer on the call to response.getEntity().getIdentifier().
The logging statements in my post method verify that I appear to have setup the
response correctly:
Verifying response.
Status: Created (201)
Identifier: /services/myService/map/26
Essentially, it appears that I'm getting a generic OK-related Response object,
the one I setup is not the one I appear to receive, am I maybe missing
something on the client side?
Thanks in advance for any insight.