Hi Sean,

[...]

> The blog post is confusing. It first says not to avoid
> content negotiation but goes on to propose a solution that avoids 
> content negotiation by assigning unique URIs to each representation.

Content negotiation is a useful feature and it's great to be able to
leverage it easily. Sometimes, you want to consider each resource's
representation as a resource in itself.

The ability to pinpoint specific representations is also necessary due
limitations of many HTTP clients, like AJAX clients or Web browsers which
don't always correctly populate their Accept header, especially IE which
prefers Word documents over HTML pages :)
 
> We'd like to have a single resource and URI (GET 
> http://host:port/service/foo)
> and return HTML if the client is a browser, and return something more
> machine friendly for a web service client. We use a lot of 
> XML with JAXB and we have been specifying APPLICATION_XML for JAXB. 
> It would be nice if there was some better (more distinguishing) media 
> type for that. 

You are absolutely free to specify your own XML media type. Just instantiate
the MediaType class manually instead of using built-in media types.

Then, make sure that your Web service client correctly specifies its Accept
header to prefer this custom media type. With the Restlet client API, this
is easy to do via the Request.clientInfo.accepted* properties.
 
> In a service I'm creating now, I'm looking at using JSON and 
> that seems
> to avoid these problems to some extent. That's great for me, 
> but other of
> our services pass complex data which benefits from JAXB.
> 
> I'd also like to hear people's thoughts.

I hope that my answer was helpful.

Best regards,
Jerome  

Reply via email to