On Feb 17, 2007, at 12:46 PM, Ryan McDonough wrote:
> I have been reading through the WADL docs and I was wondering if
> the following scenario is covered by the current spec:
>
> I have a RESTful service is responsible for assigning unique
> identifiers to a given resource. In a nutshell, persistence is done
> via Hibernate 3 and XML marshaling is handled by JAXB2. When my
> code issues a POST or a PUT to create a new contact at the
> following URL:
>
> http://mydomain/contacts
>
> Since identifier is unknown by the client at this point, the
> service will assign a new ID to the contact and persist the
> contact. In order for the client get the new resource, the code
> issues a redirect to the new location:
>
> http://mydomain/contacts/33127
>
> I'm issuing a 301 (Moved Permanently) since this is the new
> permenant location of the resource.
>
Shouldn't you be returning a "201 Created" instead with the Location
header containing the URI of the new resource ?
> With all of that said, I have not seen anything in the WADL spec
> that would represent this kind of behavior. I'm curious to know if
> following a redirect would be implicit if a there is a
> representation value on a PUT or POST call? Thanks.
>
WADL doesn't try to reproduce the HTTP spec, in general a client
should be prepared to accept any HTTP status code following a request
and support for things like redirection is implicit.
That said, there is a facility to specify the HTTP status code on a
representation and you can use that to differentiate between
different representations that could be returned for different status
codes.
Thanks,
Marc.
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.
- application/pkcs7-signature attachment: smime.p7s