Archive for April, 2004

A processThis Recap

Monday, April 26th, 2004

I’m a recent entrant to the blogging community, but I was getting so much out of one side of the conversation, I wondered how much better having both sides would be. I suppose I knew that someone would eventually respond to one of my entries, but I still managed to be surpised when it happened!

Jim Webber stumbled across my entry on uniform interface, and took issue with requiring an interface definition for a web service. His commentary there, and Savas’ recent piece, On the REST verbs vs. “processThis” discussion, are helping me understand their position.

Some key points that I missed early on:

  • processThis is an imaginary method
  • the imaginary processThis method has the same semantics as POST does in REST, but can be bound to any underlying transport mechanism
  • processThis by itself is constraintless
  • WSDL constrains which messages are exhanged and how that happens.

To come back to concrete examples, let me offer the following:

I want to find some light reading for my upcoming vacation. I send a message to BookMonger, Inc. requesting books on Web Services. Let’s say that is a TopicSearch message. BookMonger returns me a TopicSearchResult message with some titles, descriptions, prices, etc. I form and submit a BookOrder to order Jim’s book “Developing Enterprise Web Services: An Architect’s Guide”. BookMonger sends back an OrderStatus indicating that the order is approved and that they expect it to ship within 24 hours. I’m impatient, and I send an OrderStatusInquiry every hour to check on my order. BookMonger obligingly responds with an OrderStatus each time. When the book (finally!) ships, they send me an unsolicited OrderStatus letting me know that the order has shipped.

There appear to be as few as two endpoints involved in this exchange. One for BookMonger, and one for me (to receive that unsolicited OrderStatus message). Perhaps the BookMonger endpoint is bound to HTTP, since BookMonger’s services seem to be mostly request/response. My endpoint is receive-response-only, and so might be bound to SMTP.

Any time a message is posted to an endpoint, the endpoint recognizes the message and handles it. In this way, the imaginary processMessage verb is invoked.

Not every endpoint recognizes every message, though. If I posted my BookOrder message to ToasterMonger, they wouldn’t know what to do with it and would presumably reject my message. And so enter WSDL. WSDL seems capable of making it clear that ToasterMonger doesn’t accept book orders; ToasterMonger wouldn’t define a BookOrder message.

BookOrderShredders, on the other hand, could conceivably define a BookOrder, but surely the results of posting a message to their endpoint are different! So I potentially have to distinguish between the outcomes of posting the same message to two different web services. I’m not aware that WSDL provides the means for making this distinction. Savas claims that

There are no semantics attached to the imaginary ?receiveMessage?

They must be attached to something, though, so I suppose that it’s the combination of the endpoint and the message.

Thanks for putting your thoughts out there, guys. Is this an accurate description of the processThis concept? Jump in and clarify it for me.

Reliable HTTP POST

Wednesday, April 21st, 2004

A couple of ideas I don’t want to lose regarding how to POST reliably in HTTP :

Mark Nottingham and Paul Prescod recommend similar solutions. The server gives out unique URIs for handling POSTs. These URIs accept only a single POST, preventing multiple POSTs from causing duplication.

Mark suggests that a second POST respond with status information:

If the server receives more than one POST to any particular ‘action’ link, it should generate a message saying “This order has already been submitted,” perhaps along with a summary of the order and its status.

Paul takes a different approach:

The response of subsequent POSTs should be the same as if there had been only one POST so that the client can get the correct response even if there is a network outage in the middle of the first response.

John Beatty has a nice follow-up article in which he points out that this kind of behavior might not be RESTful. The server has to remember ephemeral application state (the request identifier) from a previous request in order to service the current request.

Mark Baker weighs in:

There are actually ways of doing id generation on the server and still having it be stateful [I think Mark means to say “stateless” here. –mgarland] though; generate a URI on the server, and pass it to the client with the intent that the data be PUT to that URI. That way you get to use the idempotence of PUT, though at the cost of another round trip. But that could be amortized by sending a batch of URIs which can be reused as the client sees fit.

This puts the state back on the client in the form of a URI. Presumably, the server can extract enough state from the URI to serve the resource.

I toyed with the thought of using GET to find the unique URI. Then POST to the unique URI creates the resource at the URI, at-most-once, and must occur before PUT, GET, or DELETE to that URI make sense.

But I suspect that doing so may lead to race conditions that require the client to two-step with (409) Conflict, and it might also violate the definition of POST:

accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line

I’d love to hear informed opinions on this. For now, I’m POSTing to get the unique URI and PUTing the desired state.

On REST’s Uniform Interface

Monday, April 12th, 2004

Jim Webber suggests that a single verb is a sufficent “uniform interface”, and wonders why more are necessary. Mark Baker responds that POST is what Jim is describing, but makes a good case for including GET. And to Mark’s comment

That’s really good to hear you say that Web services have uniform semantics. But it’s impossible for them to be more uniform than REST, because REST prescribes uniform interface semantics by definition. - Mark Baker

Bill de hÓra replies:

I have to admit I don’t get this. What does it mean? - Bill de hÓra

(more…)

Foundations for components and service models

Wednesday, April 7th, 2004

Bill de hÓra offers some good guidance on service model evolution:

The core problem of component and service architectures is easy to express: how do I change a published interface without breaking the callers?

I’ve summarized the major points and made some additional notes from a .NET background (with an eye toward REST).

(more…)

Automated interactions in REST

Monday, April 5th, 2004

Mark Baker and Savas are discussing service description. Mark suggests that its better for the interface and description to be dynamically negotiated. Is this workable in practice, or just ivory tower? (more…)