DotNetBlocks

Things on DotNet, programming, and other useless stuff

When to use SOAP over REST

So, how does REST based services differ from SOAP based services, and when should you use SOAP? Representational State Transfer (REST) implements the standard HTTP/HTTPS as an interface allowing clients to obtain access to resources based on requested URIs. An example of a URI may look like this http://mydomain.com/service/method?parameter=var1&parameter=var2. It is important to note that REST based services are stateless because http/https is natively stateless. One of the many benefits for implementing HTTP/HTTPS as an interface is can be found in caching. Caching can be done on a web service much like caching is done on requested web pages. Caching allows for reduced web server processing and increased response times because content is already processed and stored for immediate access. Typical actions performed by REST based services include generic CRUD (Create, Read, Update, and Delete) operations and operations that do not require state.

Simple Object Access Protocol (SOAP) on the other hand uses a generic interface in order to transport messages. Unlike REST, SOAP can use HTTP/HTTPS, SMTP, JMS, or any other standard transport protocols. Furthermore, SOAP utilizes XML in the following ways:

  • Define a message
  • Defines how a message is to be processed
  • Defines the encoding of a message
  • Lays out procedure calls and responses

As REST aligns more with a Resource View, SOAP aligns more with a Method View in that business logic is exposed as methods typically through SOAP web service because they can retain state. In addition, SOAP requests are not cached therefore every request will be processed by the server.

As stated before Soap does retain state and this gives it a special advantage over REST for services that need to preform transactions where multiple calls to a service are need in order to complete a task. Additionally, SOAP is more ideal for enterprise level services that implement standard exchange formats in the form of contracts due to the fact that REST does not currently support this.

A real world example of where SOAP is preferred over REST can be seen in the banking industry where money is transferred from one account to another. SOAP would allow a bank to perform a transaction on an account and if the transaction failed, SOAP would automatically retry the transaction ensuring that the request was completed. Unfortunately, with REST, failed service calls must be handled manually by the requesting application.

References:

  • activey@doaplatform.org

    11/21/2011 9:14:00 AM |

    Say what?
    SOAP provides transaction failover machanism?
    Don't think so dude ...

  • john

    11/21/2011 2:56:11 PM |

    Hi ,

    Great post, it gives me good info. Thanks for sharing.

  • pc wallpapers

    11/28/2011 2:21:13 AM |

    Resources like the one you mentioned here will be very useful to me!

  • saldytuvai

    12/7/2011 6:26:06 AM |

    Love your website, will be preventing back again.

  • Jeffrey Damian

    12/7/2011 3:46:33 PM |

    This is such a good blog, how can i subscribe?

  • Clementine Conces

    12/18/2011 7:35:48 PM |

    Documentation les actus de mutuelle directeur g�n�ral de mutuelle la de mutuelle vous reconnecter.

  • Best IM Software

    1/3/2012 11:46:08 PM |

    Thanks for the great post. It was very edifying and I liked reading it. Since you are an internet marketer like I am, you might be interested in this new No Hands SEO Software.  You get massage backlinks instantly and you can index your new site quickly. Add your website and anchor texts and and watch the software to its work.  Simple as that,, no more learning the software and getting frustrated. Try the software out today.

Pingbacks and trackbacks (1)+

Comments are closed