Putting SOAP to REST

3,420 views
3,198 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,420
On SlideShare
0
From Embeds
0
Number of Embeds
450
Actions
Shares
0
Downloads
126
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Putting SOAP to REST

  1. 1. SOAP vs. REST<br />Putting SOAP to REST<br />Igor MoochnickIgorShare Consulting<br />igor@igorshare.com<br />Blog: www.igorshare.com/blog<br />
  2. 2. It’s not about one vs. another, but it’s about more tools in your toolbox<br />
  3. 3. SOAP Call<br />POST http://igorshare.com/weather HTTP/1.1<br />Content-Type: application/soap+xml<br />Content-Length: 198<br />&lt;?xml version=&quot;1.0&quot;?&gt;<br />&lt;soap:Envelopexmlns:soap=“http://...” soap:encodingStyle=&quot;http://...&quot;&gt;&lt;soap:Bodyxmlns:m=&quot;http://igorshare.com/weather&quot;&gt;  &lt;m:GetTemperature&gt;    &lt;m:Zip&gt;02451&lt;/m:Zip&gt;  &lt;/m:GetTemperature &gt;&lt;/soap:Body&gt;<br />&lt;/soap:Envelope&gt;<br />REST Call<br />GET http://igorshare.com/weather/?zip=02451 HTTP/1.1<br />Content-Type: application/json<br />
  4. 4. HTTP Methods<br />
  5. 5. HTTP Methods like CRUD<br />
  6. 6. SOAP<br />Mature tool support<br />Transport Independence<br />Headers are inside the message<br />Send SOAP envelope over SMTP, FTP, MSMQ, JMS, …<br />WS-*<br />WS-Security<br />WS-ReliableMessaging<br />WS-AtomicTransaction<br />WS-BusinessActivity<br />
  7. 7. Why REST<br />Good performance<br />Scalable<br />Easy to build and maintain (simplicity)<br />Easy monitoring<br />Reliable (handling failure, failover, …)<br />Easy to use and test<br />Constraints:<br />Uniform interface<br />Addressable<br />Connectedness<br />Stateless<br />Cacheable<br />
  8. 8. ROA<br />Resource Oriented Architecture<br />Addressability<br />Connectedness (guide from state to state)<br />Stateless<br />Uniform Interface<br />Every resource should be addressable<br />Bookmark<br />Email<br />Link<br />Monitoring<br />Easy to test<br />
  9. 9. REST<br />Simplicity<br />Multiple representations – JSON, CSV, XHTML, XML, etc…<br />Human Readable Results<br />Performance:<br />Scalable architecture<br />Lightweight requests and responses<br />Easier response parsing<br />Bandwidth saving tools (caching, conditional GET, …)<br />Perfect for AJAX clients (using JSON representation)<br />
  10. 10. REST (Advanced)<br />Security<br />SSL – encryption: proven track record (SSL1.0 from 1994)<br />Basic authentication<br />Digest authentication<br />WSSE Username Token<br />Transactions<br />No specific HTTP headers are available<br />Many options are available, can use multiple POST/PUT<br />Think of “shopping cart”<br />
  11. 11. REST (Advanced)<br />Conditional GET (bandwidth saving tool)<br />
  12. 12. REST (Advanced)<br />Caching<br />Expires: {date}<br />Cache-Control: {age/no-cache}<br />Look Before You Leap (saves bandwidth)<br />PUT /…/{id}<br />Expect: 100-Continue<br />Result codes:<br />417 (Expectation Failed) // If service rejects request<br />100 (Continue) // If service accepts request<br />
  13. 13. HTTP Success Status Codes<br />
  14. 14. HTTP Redirection Status Codes<br />
  15. 15. HTTP Error Status Codes<br />
  16. 16. HTTP Server Error Status Codes<br />
  17. 17.
  18. 18. REST Weaknesses<br />Confusion (high REST vs. low REST)<br />Is it really 4 verbs? (HTTP 1.1. has 8 verbs: HEAD, GET, POST, PUT, DELETE, TRACE, OPTIONS, and CONNECT)<br />Mapping REST-style synchronous semantics on top of back end systems creates design mismatches (when they are based on asynchronous messaging or event driven interaction)<br />Cannot deliver enterprise-style “-ilities” beyond HTTP/SSL<br />Challenging to identify and locate resources appropriately in all applications<br />Apparent lack of standards (other than URI, HTTP, XML, MIME, HTML)<br />Semantics/Syntax description very informal (user/human oriented)<br />
  19. 19. WADL<br />WADL (Web Application Description Language)<br />Not a widely used as WSDL<br />My opinion: overkill<br />Most REST services are self-documented or have a textual description<br />
  20. 20. WADL Example<br />&lt;application xmlns:xsi=“…”&gt;<br /> &lt;grammars&gt;<br /> &lt;include href=&quot;ticker.xsd&quot;/&gt;<br /> &lt;/grammars&gt;<br /> &lt;resources base=&quot;http://www.example.org/services/&quot;&gt;<br /> &lt;resource path=&quot;getStockQuote&quot;&gt;<br /> &lt;method name=&quot;GET&quot;&gt;<br /> &lt;request&gt;<br /> &lt;param name=&quot;symbol&quot; style=&quot;query“ type=&quot;xsd:string&quot;/&gt;<br /> &lt;/request&gt;<br /> &lt;response&gt;<br /> &lt;representation mediaType=&quot;application/xml&quot; <br /> element=&quot;ex:quoteResponse&quot;/&gt;<br /> &lt;fault status=&quot;400&quot; ediaType=&quot;application/xml&quot; <br /> element=&quot;ex:error&quot;/&gt;<br /> &lt;/response&gt;<br /> &lt;/method&gt; <br /> &lt;/resource&gt;<br /> &lt;/resources&gt;<br />&lt;/application&gt;<br />
  21. 21. So what’s RDF?<br />Resource Description Framework<br />Doesn’t require fore-knowledge of type<br />Applies common ontology<br />High discoverability<br />Great framework. Terrible metaphor.<br />Subject/Predicate/Object ??<br />Entity/Attribute/Value !!<br />
  22. 22. RDF Example<br />&lt;?xml version=&quot;1.0&quot;?&gt;<br />&lt;rdf:RDFxmlns:rdf=&quot;...” xmlns:cd=&quot;...&quot;&gt;<br />&lt;rdf:Descriptionrdf:about=&quot;http://www.recshop.fake/cd/Empire Burlesque&quot;&gt;<br /> &lt;cd:artist&gt;Bob Dylan&lt;/cd:artist&gt;<br /> &lt;cd:country&gt;USA&lt;/cd:country&gt;<br /> &lt;cd:company&gt;Columbia&lt;/cd:company&gt;<br /> &lt;cd:price&gt;10.90&lt;/cd:price&gt;<br /> &lt;cd:year&gt;1985&lt;/cd:year&gt;<br />&lt;/rdf:Description&gt;<br />&lt;rdf:Descriptionrdf:about=&quot;http://www.recshop.fake/cd/Hide your heart&quot;&gt;<br /> &lt;cd:artist&gt;Bonnie Tyler&lt;/cd:artist&gt;<br /> &lt;cd:country&gt;UK&lt;/cd:country&gt;<br /> &lt;cd:company&gt;CBS Records&lt;/cd:company&gt;<br /> &lt;cd:price&gt;9.90&lt;/cd:price&gt;<br /> &lt;cd:year&gt;1988&lt;/cd:year&gt;<br />&lt;/rdf:Description&gt;<br />&lt;/rdf:RDF&gt;<br />
  23. 23. More Info….<br />Fiddler Web Proxy Tool (http://fiddler2.com/fiddler2/ )<br />WCF ReST Starter Kit (http://msdn.microsoft.com/en-us/netframework/cc950529.aspx)<br />PluralSightScreencast – Aaron Skonnard (http://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Consuming-REST-services-with-HttpClient/)<br />

×