On Jul 13, 2008, at 10:11 AM, Norman Gray wrote:
>
> [I'm experimenting with WADL for the first time, so apologies if I'm
> misunderstanding something]
>
> In the WADL spec, the status of an HTTP transaction is modelled in
> the <representation> element. This seems eccentric, and I'm
> wondering if I'm missing some constraint.
>
> There was a brief discussion of this in February (I see from the
> archive <https://wadl.dev.java.net/servlets/ReadMsg?list=users&msgNo=59
> >), but it was inconclusive, and ended with Marc Hadley saying
>> I suppose allowing multiple sibling Response elements and having
>> the status on those might be more amenable to what you are trying
>> to do.
> Though I'm not sure whether this was a suggestion, or thinking-aloud
> about a fix.
A bit of both. I think the suggested refactoring makes sense and I've
added an issue to track this:
https://wadl.dev.java.net/issues/show_bug.cgi?id=13
Marc.
> If the latter, then yes, I think that the following would make more
> conceptual and practical sense.
>
> <response status='200'>
> <representation mediaType='text/html'>
> ....
>
> The problem is that the HTTP status in the response, and the
> representation enclosed in the response, are very distinct, so that
> conceptually they have no business being coupled together so closely
> as they are in the current model.
>
> RFC2616 defines a 'representation' as
>
>> An entity included with a response that is subject to content
>> negotiation, as described in section 12. There may exist
>> multiple
>> representations associated with a particular response status.
>
> That indicates that the representation is _part_ of a response, and
> the status is a separate part of the response, and not part of the
> representation.
>
> More practically, the current WADL model means that if I have two
> resources, say /A and /B, which both return text/html, but a POST
> to /A returns HTML with a 201 status, and a GET to /B returns HTML
> with a 200 status, I can't do
>
> <resource name="A">
> <method name='POST'>
> <representation href='#html'/>
> </method>
> </resource>
> <resource name="B">
> <method name='GET'>
> <representation href='#html'/>
> </method>
> </resource>
> ...
> <representation id='html' mediaType='text/html'>
> <doc>A full discussion of HTML, with references and whatnot</doc>
> </representation>
>
> It wouldn't do to say
>
> <representation id='html' mediaType='text/html' status='200,201'/>
>
> since that doesn't let me say that only /A responds 201 and only /B
> responds 200. The alternative is to have separate <representation>
> elements within the two <resource> elements, but that would mean I'd
> have to either duplicate or omit the possibly elaborate
> documentation of the #html response representation.
>
> For the sake of concreteness, can I therefore suggest the following
> as alterations to the WADL schema
>
> method =
> element wadl:method {
> (
> (
> attribute href { xsd:anyURI }
> ) | (
> doc*,
> request?,
> response*, ### instead of response?
> attribute id { xsd:token }?,
> attribute name {
> "DELETE" | "GET" | "HEAD" | "POST" | "PUT" | xsd:token
> }
> )
> ),
> foreign-element,
> foreign-attribute
> }
> response =
> attribute status { xsd:int }, ### addition
> element wadl:response { <blah> }
>
> ...and omit attribute 'status' from representation_type.
>
> Best wishes,
>
> Norman
>
>
> --
> Norman Gray : http://nxg.me.uk
> Physics and Astronomy, University of Leicester
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_wadl.dev.java.net
> For additional commands, e-mail: users-help_at_wadl.dev.java.net
>
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.