Just joking⌠I havenât come up with yet another specification. While travelling to Seoul, however, I was thinking about the on going discussion on REST vs SOAP. This is my small contribution to this discussion: An implementation of the âWebâ using SOAP đ
Background reading
Lately the REST and SOAP folks have been busy arguing about which approach is better for Internet-scale systems as a result of Carlos Perezâs three-part post on âWhy REST is betterâ (part 1, part 2, part 3). First, some background readingâŚ
In his posts, Chris made some excellent counterarguments to Carlosâ position. BTW⌠Something that Chris didnât point out to Carlos is that the HTTP operations being used in the examples to support the REST case are also RPC since thatâs the nature of the HTTP operations. Which brings me to this⌠HTTP != REST. HTTP is just an implementation technology that can be used to build RESTful applications but it can be easily abused to build applications following different architectural styles (cookies anyone? đ
REST vs SOAP â Apples and Oranges
Some have argued that comparing SOAP and REST is like comparing apples and oranges. I fully agree with this position.
How can one possible compare REST and SOAP when the former is an architectural style while the latter is a piece of technology? In fact, isnât it the case that we can design an application using a particular architectural style for distributed computing and build it using any piece of technology? For example , one can build service-oriented applications using RPC and object-oriented applications using Web Services technologies (e.g. WS-RF). Of course some technologies are better suited for a particular architecture or make it easier to build applications following specific architectural principles (e.g. CORBA for distributed objects, Web Services for service-orientation).
So, in order to prove the point that SOAP should not be compared against REST, I decided to do some coding. Since I had just finished the implementation of WS-Transfer for PlumbworkOrange, I thought that it would be a great idea to use it to build a RESTful application. And of course, whatâs the most well-known application out there? The Web of course.
WS-Web
The idea is based on the following:
Architecture
Simple stuff⌠We have a Web Service that understands WS-Transfer offering access to the state representation of some Web resources and a Web browser that sends appropriately formatted SOAP messages to that Web Service.
Implementation
I used the WS-Transfer implementation, which is now part of PlumbworkOrange for both the browser and the service with WSE 2.0 implementing the underlying pluming.
For the service, I had to write a WS-Web-specific resource provider for the WS-Transfer implementation (as I explained in a previous post) which was a very simple task and only needed few lines of code. With .NET 2.0 I can even process ASP.NET 2.0 pages without needing a Web Server. Indeed, I was able to process the pages of my web site but, unfortunately, the output is not fully XHTML-compliant so I couldnât return the pages as SOAP payloads in XML. I just had to write few simple XHTML pages for testing.
The browser was simple too and only needed about 20 lines of code. I used .NET 2.0âs Web Browser control. The Web Browser control is not allowed to navigate when a link in a page is selected (it wouldnât be able to navigate to it anyway since all the links use the âurnâ scheme). Instead, a SOAP message, like the one bellow, is created and sent to the Web Service.
<soap:Envelope xmlns:wsa=âhttp://schemas.xmlsoap.org/ws/2004/03/addressingâ xmlns:soap=âhttp://schemas.xmlsoap.org/soap/envelopeâ/>
  <soap:Header>
     <wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</wsa:Action>
     <wsa:MessageID>uuid:7b1fb9e4-7347-47d8-b03d-e3bc05048492</wsa:MessageID>
     <wsa:ReplyTo>
        <wsa:Address>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:Address>
     </wsa:ReplyTo>
     <wsa:To>soap.tcp://localhost:10000/web</wsa:To>
     <wsweb:WebResourceId xmlns:wsweb=âurn:ws-webâ>urn:ws-web:page1.html</wsweb:WebResourceId>
  </soap:Header>
  <soap:Body />
</soap:Envelope>
This is a typical normal WS-Transfer request. The <wsweb:WebResourceId> header identifies the resource. The reply to the above message is:
<soap:Envelope xmlns:wsa=âhttp://schemas.xmlsoap.org/ws/2004/03/addressingâ xmlns:soap=âhttp://schemas.xmlsoap.org/soap/envelope/â>
  <soap:Header>
     <wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse</wsa:Action>
     <wsa:MessageID>uuid:b0bf1724-8779-4502-bb2b-a8e83c0cd6aa</wsa:MessageID>
     <wsa:RelatesTo>uuid:f3590721-b139-4d3b-94e9-8530321fbe96</wsa:RelatesTo>
     <wsa:To>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:To>
  </soap:Header>
  <soap:Body>
     <htmlxmlns=âhttp://www.w3.org/1999/xhtmlâ>
        <head>
           <title>Untitled Document</title>
        </head>
        <body>
           <p>This is page 1.</p>
           <p>back to <a href=âurn:ws-web:index.htmlâ>home</a>.</p>
        </body>
     </html>
  </soap:Body>
</soap:Envelope>
The body of the SOAP message contains the representatin of the resource; in this case an XHTML page. Hereâs a screenshot of the browser (please note that I am using SOAP over TCP/IP to access my WS-Web site đ
Currently, only the GET operation is supported but I think this is enough to prove the point.
Conculsion
We all know that creating a REST-style application is not coupled with the use of HTTP. So, there is no reason why SOAP couldnât be used to create REST-style applications. In fact, I would argue that building the Web on top of SOAP has great advantages like end-to-end security, maintaining the intermediary-based architecture of REST for caching, the header-based extensibility, arbitrary transports even for a single message, tooling support for implementations, etc. The huge disadvantage of the approach, though, is the already widely-deployed HTTP-based infrastructure. I donât expect the Web to move to WS-Web any time soon đ
Both the REST and WS communities have a lot to learn from each other. We should constructively educate one-another and learn from what âthe other sideâ has to say instead of declaring each otherâs demise. For what itâs worth, I feel that I have learned a lot from the discussions with the REST folks and together with Jim we hope to move that understanding forward to service-oriented computing with our upcoming MEST paper.
Update: Formatting fixed.
I am embarking on a side project that involves memory and multimodal understanding for an…
I was in Toronto, Canada. I'm on the flight back home now. The trip was…
The BBC article "How we fell out of love with voice assistants" by Katherine Latham…
Like so many others out there, I played a bit with ChatGPT. I noticed examples…
Hi all⌠Itâs been a while since I posted on this blog. Itâs been an…