Media Types, Plumbing and Democracy

Updated 2 months ago

Source: http://www.subbu.org/

One of the recurring debates in the REST community is the use of media types. There are two opinions about the use of media types.

Opinion 1: Web services must use standard media types to be RESTful.

Opinion 2: Custom media types are necessary to keep interactions visible, and to serve as contracts.

Of these, the first one is based on a literal interpretation of the following from Roy Fielding’s thesis (emphasis mine).

REST enables intermediate processing ...

  • 26 comments on this story
PRO

50% positive

Showing 19 relevant reactions out of 26.

My blog post on media types is now 15 pages long in print with all the comments - http://bit.ly/6ARAgP

2 months, 1 week ago by sallamar on Twitter

Once the message gets into the app runtime (e.g. JAX-RS) routing is not a big problem, but I am talking about the message routing from the time it reaches some front-end proxy till the time it is fed into a runtime. This gets more interesting when you consider homegrown/commercial CDNs setup with origin servers half-way across the globe. When developers make choices about URIs and media types, they ... See all content

2 months, 1 week ago by subbu on Wordpress

JAX-RS can route based on media type. That is not the problem. The problem resides in the fact that most (all?) JAX-RS implementations are built on top of a servlet container. Each web deployment is its own classloader and thus you can’t version classes within it. I don’t know of any servlet implementations that allow you to bind different web deployments to the same URL scheme.

2 months, 1 week ago by Bill Burke on Wordpress

In Java land, with the current tools available, it would be very hard to implement a common URL scheme that served up different versions of the same application using conneg.

This is exactly the problem I was referring to in my comment about routing rules.

2 months, 1 week ago by subbu on Wordpress

I don’t think your PO/Album example is a good one. A better one would be an Oracle Financials PO vs. a SAP PO. Or a Saleforce.com contact vs. a Thunderbird contact. If a client receives a URL how is it supposed to ask for, or find out a specific XML format exists? Conneg + custom media types is one way. Links are another. One causes an explosion of media types, the other an explosion of links ... See all content

2 months, 1 week ago by Bill Burke on Wordpress

@stilkov http://trunc.it/4p34z on media types in REST: 'If the goal is versioning, use version identifiers in URIs.' What do you think?

2 months, 1 week ago by cretzel on Twitter

Interesting discussion about media types in RESTful apps http://j.mp/8dHfuE

2 months, 1 week ago by ferdy on Twitter

I think his assertion that “A REST API should spend almost all of its descriptive effort in defining the media type(s) used for representing resources” argues for the use of custom mime types. Otherwise it would have been more correct to say “choosing the media types”.

It is not more correct to say “choosing” as this would preclude creation of new media types. Neither
... See all content

2 months, 1 week ago by Eric J. Bowman on Wordpress

A small variation I’ve had success with is to stick with standard media types but to add link headers with further type (or at least type-like) information.

In described_routes (on hold unfortunately while the URI Template standard gets redrafted), the type identifiers come in the form of URIs that point to URI Template-based metadata, making the application nicely self-describing and
... See all content

2 months, 3 weeks ago by Mike Burrows on Wordpress

Social comments and analytics for this post…

This post was mentioned on Twitter by mamund: Media Types and Plumbing http://ff.im/-dgjLN…

2 months, 4 weeks ago by uberVU - social comments on Wordpress

Interestingly, there are several who would disagree with your interpretation. Having watched/participated in this debate a few times, I remain agnostic of either interpretation.

It is better to go beyond the terminology and interpretations and look at the problem being solved and its viability. If you’re convinced that your XML needs a new media type, just make sure that there are no
... See all content

2 months, 4 weeks ago by subbu on Wordpress

Hi, Thanks for another great post.

My understanding is Adam’s, and I arrived via the same quote of Feilding’s. So I’d appreciate your thoughts no his comments/observations.

On the version issue: I’d come to the point of thinking it is so endemic it should be dealt with at the entry point. Taking Roy’s HATEOS literally I thought to make versioning such
... See all content

2 months, 4 weeks ago by Hedge on Wordpress

Subbu,

I don’t think Dr. Fielding intended for the first option to be the “correct” understanding of how to use mime types. In his blog post of last year titled REST APIs must be hypertext-driven he writes:

A REST API should spend almost all of its descriptive effort in defining the media type(s) used for representing resources and driving application state, or
... See all content

2 months, 4 weeks ago by Adam on Wordpress

Subbu:

great to see you are blogging again ! Pete, good to see you are still working on the versioning problem. That’s a hard one to crack.

This discussion sounds a bit heretic to me and I am afraid Roy is going to slap both of you on the wrist.

The real RESTful way to handle interactions is “bookmarks”. Bookmarks can have versions in their URI. You are
... See all content

2 months, 4 weeks ago by Jean-Jacques Dubray on Wordpress

Versioning is not cheap. In any case, as we debated in the past versioning by media types does not fly for non-XML types.

Regarding your question, penalty of using custom media types for the sake of communicating semantics to custom application code is high. It goes up with the size of the service.

2 months, 4 weeks ago by subbu on Wordpress

Version ids in URIs is a safe bet, but not a cheap one. It’s hard to implement on the server side and, at least for some types of clients,hard to implement on the client side. It makes it more difficult to evolve applications and to decommission obsolete formats.

You didn’t really answer the final questions in my previous comment. I see the appeal of staying on the beaten path
... See all content

2 months, 4 weeks ago by Peter Williams on Wordpress

Hi Peter,

I gave namespace as an example for code to figure out a way to learn about the XML. For versioning, using version identifiers in URIs is a safe bet.

If the key motivation is to communicate application semantics, then there are cheaper ways. Sometimes, the client "just knows".

2 months, 4 weeks ago by subbu on Wordpress

When using namespaces to determine the semantics of the message how do you cope with an evolving set of application semantics? For example, consider the situation where the server needs to introduce some new semantics that are incompatible with existing PO format. How would you go about providing the new format to those clients that can handle it while simultaneously providing older clients with the ... See all content

2 months, 4 weeks ago by Peter Williams on Wordpress

Media Types and Plumbing: On the other hand, most of the HTTP plumbing (e.g. proxies and firewalls), and HTTP plumb... http://bit.ly/6C424e

2 months, 4 weeks ago by SeattlePlumbing on Twitter

© uberVU Ltd. 2010

Terms of use
FEEDBACK