Slashdot Mirror


REST vs. SOAP In Amazon Web Services

tadghin writes "I was recently talking with Jeff Barr, creator of syndic8 and now Amazon's chief web services evangelist. He let drop an interesting tidbit. Amazon has both SOAP and REST interfaces to their web services, and 85% of their usage is of the REST interface." Read on for some more thoughts and information on REST and Web services, including information about a free Web services seminar on April 22nd. " Despite all of the corporate hype over the SOAP stack, this is pretty compelling evidence that developers like the simpler REST approach. (I'm sure there are applications where SOAP is better, but I've always liked technologies that have low barriers to entry and grassroots adoption, and simple XML over HTTP approach seems to have that winning combination.)

Amazon's web services have attracted a thriving community, people are making real money building alternate interfaces to Amazon and collecting Associates commissions on the resulting sales, and there are even tool developers who have come up with the creative business model of agreeing with their users to have some percentage of the transactions use the tool developer's Associates id rather than the site owner's. Cool.

Amazon is holding a free all day web services workshop on April 22 at the O'Reilly Emerging Technologies Conference. The event is open to people not registered at the conference (though space is limited to 50 people).

P.S. Slashdot really ought to have web services as a topic area! Despite being over-hyped, this is a really important area, and there's a lot cooking. Amazon's web services"

29 comments

  1. REST or SOAP: yes by jnana · · Score: 4, Insightful
    Just how do you submit a complex transactional XML document using REST? Parsing a URL query string with 200 name-value pairs, then assembling that back into the XML document that the recipient expects does not seem like a good solution. Surely, submitting a SOAP document that wraps the XML document is better in this case.

    It is understandable that Amazon sees most people using REST. They're mostly hobbyists and amateur programmers, and REST is easier and sufficient for the very simple things that you can do via the Amazon web services api, but if one were trying to submit more information -- say a long purchase order -- the limitations of REST would be more apparent. The RPC style of SOAP is often better with REST, but for the document-exchange style, REST is inadequate.

    1. Re:REST or SOAP: yes by pmz · · Score: 2, Interesting

      They're mostly hobbyists and amateur programmers, and REST is easier and sufficient for the very simple things that you can do via the Amazon web services api, but if one were trying to submit more information -- say a long purchase order -- the limitations of REST would be more apparent.

      I would bet there are significant numbers of professionals using REST, too. It has a pretty high usefulness threshold, because a lot of tasks don't require the complex hierarchical datasets allowed by XML.

      I've personally used REST instead of SOAP in an internal project, because REST is simple to implement and totally adequate for what we were trying to do. SOAP would have required: learning, sorting through buzzwords, more learning, some more sorting, and a prototype before actually creating a working system. Basically, SOAP has a higher learning curve that can (and should) be avoided when possible. Also, the tools and libraries for SOAP are much younger than those for REST.

    2. Re:REST or SOAP: yes by peterdaly · · Score: 1

      This webservice is not complicated enough for SOAP to be worth while.

      Parsing a URL query string with 200 name-value pairs, then assembling that back into the XML document that the recipient expects does not seem like a good solution.

      That does not describe Amazon's interface. There are a handful of parameters at most.

      SOAP is not the best solution for all problems like this. In the Amazon case, REST may be better in some (many?) cases.

      -Pete

    3. Re:REST or SOAP: yes by Fweeky · · Score: 1

      REST is not mutually exclusive from PUTing or POSTing a complex XML document when necessary. SOAP, however, does make simple GET operations stupidly overcomplex and hard to cache.

    4. Re:REST or SOAP: yes by smallpaul · · Score: 2, Informative

      You don't undestand what REST is. There is nothing about REST that disallows the posting of an XML document. The question is how you use URLs and HTTP verbs, not what syntax you use. You say that "surely submitting a SOAP document that wraps an XML document is..." There is no question that XML is the right choice in some cases. That's why REST and XML are so often used together. But if you're going to claim that there is some benefit in "wrapping" the XML in SOAP, you'll have to back it up. In my experience, the vast majority of people "wrap" XML in SOAP but don't have any reason for doing so other than buzzword compliance.

    5. Re:REST or SOAP: yes by Kopretinka · · Score: 2, Informative
      Just how do you submit a complex transactional XML document using REST? Parsing a URL query string with 200 name-value pairs, then assembling that back into the XML document that the recipient expects does not seem like a good solution.

      The above shows just how little jnana understands REST. Note that SOAP over HTTP uses POST and does not do any URL encoding of the requests. Just why can't a simple HTTP application do the same?

      HTTP GET is to be used for retrieval only, and all URL encoding that may happen is only to identify the particular resource. In a well designed REST application no complex data structures need to go into the GET URL. For submissions to processing, there is the POST method.

      The real difference between SOAP and REST is that currently the only protocol designed around REST is an application protocol for hypermedia transfer whereas SOAP is a general protocol upon which application protocols may be built, including RESTful ones. One of the protocols already built over SOAP is the RESTless RPC.

      Disclosure: I'm a member of the W3C working group that's just now finishing SOAP 1.2.

      --
      Yesterday was the time to do it right. Are we having a REVOLUTION yet?
    6. Re:REST or SOAP: yes by j7953 · · Score: 2, Informative
      Just how do you submit a complex transactional XML document using REST?

      You can use HTTP POST with REST, so you simply POST the XML document to the appropriate URL (probably an URL that identifies some sort of handler).

      Surely, submitting a SOAP document that wraps the XML document is better in this case.

      But why do you want to wrap it?

      The thing that is "wrong" about SOAP is that everything is wrapped into a POST request, even if you aren't posting anything but simply requesting some information.

      For example, take the web service interface of some online store. I don't know Amazon's interface, but I suppose they would offer you a function to get the delivery status of your orders, and a way of sending them orders. With SOAP, if you want to send them an order, you'll have to wrap the order into a SOAP message call. With REST, you'd simply POST the order to an appropriate ressource, like http://webservice.example.com/newOrder. What an order looks like isn't defined by either SOAP or REST, so for the order itself, you'll have to build your own XML DTD (or schema or whatever) anyway. You'll also have to define a return type, obviously. In the SOAP case, that would be a SOAP message containing e.g. the order number. With REST, you could send back an application/xml response containing exactly the same data, but without the SOAP envelope.

      What about getting the status of an order? With SOAP, you would POST the appropriate method call to some ressource. With REST, you could simply send a GET request without any parameters to an appropriate URL, e.g. http://webservice.example.com/order/1234567/status . Obviously the server would need to check if the order number is valid and if the client has the permission to request the status of that order. But the HTTP protocol already defines how to handle this, there are appropriate error codes. What do you need SOAP for?

      There really isn't anything you can do with SOAP that you couldn't do with REST as well.

      Personally, I think that REST is not only simpler, but the interface also feels much more "natural", i.e. it is more consistent with how URLs and HTTP are supposed to work. I guess the main thing I dislike about SOAP is that it doesn't really utilize the full potential of the HTTP standard, HTTP is only used as a wrapper. Obviously there are situations where you want this, after all it also adds some extra flexibility. But I believe in most cases where you want a "web service" you really want a web service, i.e. you want to use HTTP anyway.

      --
      Sig (appended to the end of comments I post, 54 chars)
    7. Re:REST or SOAP: yes by Kopretinka · · Score: 1
      Oh yes, I forgot to mention that SOAP currently uses HTTP as the underlying transport protocol. By using POST only, it limits the usefulness of those resources to the rest of the HTTP World Wide Web.

      That's why SOAP 1.2 tries to allow the use of other HTTP methods where appropriate, so that ideally services using SOAP 1.2 over HTTP will be fully-fledged HTTP resources and will fit into the Web world.

      --
      Yesterday was the time to do it right. Are we having a REVOLUTION yet?
    8. Re:REST or SOAP: yes by oz_ko · · Score: 1

      erhemm...

      I think you will find that SOAP is transport agnostic - ie you could use it over SMTP in an email message.

      HTTP post is only one of the methods of delivering a SOAP envelope.

  2. In other news by the_other_one · · Score: 1

    Amazon patents the use of REST and SOAP...

    --
    134340: I am not a number. I am a free planet!
    1. Re:In other news by KILNA · · Score: 0, Troll

      In other other news, slashdot users were unaffected by the Amazon announcement due to caffein addiction and poor hygiene.

      --
      Error: PANTS NOT FOUND. Press <F1> to continue.
  3. Why Amazon provides two interfaces by darkpurpleblob · · Score: 2, Informative
    From the FAQ:
    Why does Amazon Web Services use both SOAP and XML over HTTP?

    We wanted to provide a platform that would both address the different needs of different people and provide an opportunity to further the debate between two popular Web services standards. Some developers like working with pure XML; others prefer SOAP. We didn't want to force people to use a protocol they weren't comfortable using.

  4. That explains those annoying fake Amazon sites by Anonymous Coward · · Score: 0
    Amazon's web services have attracted a thriving community, people are making real money building alternate interfaces to Amazon. . . Cool.

    It's not cool when you want to buy an item Amazon no longer stocks and you get hundreds of hits from this community, instead of real hits. To me it's just a way of tricking Google to send more people to Amazon. How many Amazon clones do we need?

  5. How Amazon Web Services came about by darkpurpleblob · · Score: 3, Interesting
    Tim O'Reilly played a integral part in getting the Amazon Web Services off the ground:

    Jeff was intrigued, and told me a day or two later that he'd discovered that his skunkworks team already had a web services API in the works. But he says that without my presentation he "might have done something stupid like shutting the project down.

    Read about the rest in Tim's weblog post.

  6. XML over HTTP is where it's at by peterdaly · · Score: 1

    I developed www.bitworm.com (Computer Books) using the XML over http service. I have never used SOAP, and have never seen a reason to. With their server side XSL translations, I retieve custom responses designed to conserve bandwidth/response when combined with my caching backend. I don't think I can do that with SOAP.

    SOAP is just too much work in the Amazon case with little ROI. XML is just as simple when used with JDom, or another simple parser.

    (Smart) people will use the right tool for the job. In this case, XMLoverHTTP is a better solution than SOAP. I am glad to see I am not the only person who thinks SOAP just isn't worth the trouble.

    -Pete

  7. Yeah, but all the big players used soap by Kagato · · Score: 2, Interesting

    Having worked with Amazon for one of Amazons largest online stores I can say SOAP is very much here to stay. Although many may use RIST, the big online partners use SOAP. Or rather Amazons implimentation of SOAP. With does some funky stuff with MIME attachments.

    Still, once you get it worked out the process is actually pretty smooth. All my complaints are about how they use their data, not how it's transported.

  8. I just switched from REST to SOAP by Anonymous Coward · · Score: 2, Interesting

    Over the weekend, I rewrote parts of my site that use Amazon data to use SOAP, with the help of nuSoap for php. It's much cleaner code now, and it just seems to work better. I originally went with REST because it's what they first offered, and I was just too lazy to update the code until now.

  9. MIME-RPC as an alternative to SOAP and XML-RPC by cpeterso · · Score: 4, Interesting

    A quiet alternative is MIME-RPC .

    MIME-RPC is a protocol for applications written in different languages and on different platforms to communicate with each other using a public standards:
    • It works with the millions of already deployed web apps and web browsers (without plugins)
    • It handles all Internet data including Unicode, JPEG, XML, etc.
    • It works over both HTTP and SMTP (web and email)
    • It protects application programmers from wire level concerns.
    • It provides complete interlanguage object serialization (cyclic refs.) as well as interlanguage messaging
    • It supports two way communication over client/server connections
    • It is easy to implement.
    • It doesn't require an extra XML parser when your application doesn't need one.
    • Its specification is short and unambiguous.
    • It leverages existing transport layer features like encryption, proxying, asynchrony, streaming/chunking, etc.

    Notes on SOAP vs MIME-RPC:
    • SOAP does not interoperate with existing browser based apps. MIME-RPC does.
    • SOAP does not do generic object serialization
    • SOAP forces the programmer to think about type coercion because it hides foreign data as base64encoded rather than labeling it with a useful type.
    • SOAP does not handle delivery of XML or other types well. MIME-RPC does.
    • The SOAP with attachments spec basically says to use MIME. If you are doing that, you might as well use MIME for everything (and therefore MIME-RPC).
    • The SOAP with attachments spec is ambiguous about the type of attached objects. Should the type be interpreted according to its mime content-type or according to some XML schema? MIME-RPC provides an unambiguous interpretation.
    • SOAP constrains method and variable names to be consistent with XML tag names. Many languages (e.g. SQL) allow method and parameter names that are not permitted in XML tags.
    • MIME-RPC is much easier to implement correctly than SOAP
    • MIME-RPC has less processing overhead than SOAP.

    1. Re:MIME-RPC as an alternative to SOAP and XML-RPC by Anonymous Coward · · Score: 0

      Maybe if they get it IETF standardized, and drop the trademark claim.

  10. Is it Evil? by stagmeister · · Score: 1

    The question is, does Amazon's REST take into account the Evil Bit? Remember, if you're evil we need to wash your mouth out with SOAP!

    --
    http://www.virtualvillagesquare.com/ Online Communities: The Next Generation
  11. Well duh! by bartok · · Score: 1

    Geeks prefer to rest than to use soap.

  12. Use some helper code by bill_mcgonigle · · Score: 3, Informative

    I have a system that uses XML/RPC but it could have just as easily been SOAP or REST and it wouldn't make a difference. I have a data structure in Java that gets put through some helper classes, then on the server side, I have a response that feeds into a module, and I get out a data structure. So, I never actually see any XML/RPC, but I still have the advantages of the interoperability of the standard. Moral: if you're doing much with any of these protocols your code could use some more abstraction.

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    1. Re:Use some helper code by tcopeland · · Score: 1

      This is so true. Your client code should look something like:

      Client client = new XMLRPCClient("host", "userid", "passwd");
      client.doStuff();

      Abstract all the underlying protocol stuff behind that Client interface and your code will be much easier to read and understand...

      Tom

  13. vuja de by Anonymous Coward · · Score: 0

    Whatta coincidence. My boss just complained that I rest too much and smell like I don't use soap.

  14. Where do xCBL and cXML fit in? by sonamchauhan · · Score: 0, Offtopic
    Can someone enlighten me how the usage (described below) of two Ecommerce dialects -- CommerceOne's xCBL and Ariba's cXML -- is classified?

    I don't think the usage below can be classified as either Web Service, XML-RPC, SOAP, or REST. However, this usage comprises the majority of XML-based Ecommerce transactions I see in mainstream business these days (I work for a large office supplies company).

    "The Usage"
    -----------------

    A business procedure (say, "place a purchase order") is executed by a simple transfer of an XML document. This XML document conforms to the standard it follows -- i.e. it is valid XML according to the standard's DTD/schema for that particular transaction.

    For example, to send an XML purchase order via HTTP POST, the buyer would do the following sort of POST (HTTP protocol approximated below):
    HTTP POST....
    Content-Type: text/xml

    <PurchaseOrder>
    <Blah....
    Note: the content type is "text-xml". There are no CGI params -- the XML document itself comprises the body of the HTTP POST. The seller sends back a synchronous response document (same TCP connection as the POST, but reverse direction). This 'sync response' must carry an HTTP 200 response header, but can also carry an XML document (this depends on the standard).
    HTTP 200/OK
    Content-Type: text/xml

    <ConfirmationOfPurchaseOrder>
    <Blah....
    The submitter party processes this response.

    Note, there are no standardised 'sections' of XML in the document (like there are with SOAP or Web-Services (unsure?) ). Also, unlike REST, there is no usage of other HTTP methods - DELETE, GET, etc -- only POST. The XML document itself specifies the procedure being carried out (a richer, and hence better, approach).

    For example, to do an order cancellantion, another XML document is POST-ed.
    HTTP POST....
    Content-Type: text/xml

    <PurchaseOrderCancellation>
    <OrderReference attrib="blah">
    <Blah....
    So, does this sort of usage have a name (besides the name of the business standard)? What advantages do other approaches like Web Services bring to the table?

  15. wow - so many standards by Anonymous Coward · · Score: 0

    SOAP
    REST
    XML-RPC
    MIME-RPC

    The great thing about standards is that there are so many to choose from ;-)

    Seriously, though, these are all just instances of two programs exchanging text. The text is just formatted differently in each case.

    People have been writing these text-transfer protocols for decades. The "benefit" of the current situation is that everybody gets to define their own standard and put a nifty name on it, then hype it around the industry to sell books.