putting soap to rest
TRANSCRIPT
SOAP mapped on REST
SOAP vs. RESTPutting SOAP to REST
Igor MoochnickIgorShare [email protected] Blog: www.igorshare.com/blog
1
Its not about one vs. another, but its about more tools in your toolbox
2
SOAP CallREST CallPOST http://igorshare.com/weather HTTP/1.1Content-Type: application/soap+xmlContent-Length: 198
02451
GET http://igorshare.com/weather/?zip=02451 HTTP/1.1Content-Type: application/json
HTTP MethodsGETRetrieve resource headers and bodyHEADRetrieve resource HEADERS ONLY POSTCreate resource (returns current state after creationhandy if server-generated resource ID is required)PUTCreate or Update resource (returns current state after update)DELETEDeletes resource
HTTP Methods like CRUDSQLRESTCREATEInsertPUTREADSelectGETUPDATEUpdatePOSTDELETEDelete/DropDELETE
SOAPMature tool supportTransport IndependenceHeaders are inside the messageSend SOAP envelope over SMTP, FTP, MSMQ, JMS, WS-*WS-SecurityWS-ReliableMessagingWS-AtomicTransactionWS-BusinessActivity
Why RESTGood performanceScalableEasy to build and maintain (simplicity)Easy monitoringReliable (handling failure, failover, )Easy to use and test
Constraints:Uniform interfaceAddressableConnectednessStatelessCacheable
ROAResource Oriented ArchitectureAddressabilityConnectedness (guide from state to state)StatelessUniform Interface
Every resource should be addressableBookmarkEmailLinkMonitoringEasy to test
RESTSimplicityMultiple representations JSON, CSV, XHTML, XML, etcHuman Readable ResultsPerformance:Scalable architectureLightweight requests and responsesEasier response parsingBandwidth saving tools (caching, conditional GET, )Perfect for AJAX clients (using JSON representation)
REST (Advanced)SecuritySSL encryption: proven track record (SSL1.0 from 1994)Basic authenticationDigest authenticationWSSE Username Token
TransactionsNo specific HTTP headers are availableMany options are available, can use multiple POST/PUTThink of shopping cart
REST (Advanced)Conditional GET (bandwidth saving tool)
RequestResponseGET //{id}200 OKLast-Modified: {date}GET //{id}If-None-Match: {date}304 Not Modified
RequestResponseGET //{id}200 OKE-Tag: {entity tag}GET //{id}If-None-Match: {entity tag}304 Not Modified
REST (Advanced)CachingExpires: {date}Cache-Control: {age/no-cache}
Look Before You Leap (saves bandwidth)PUT //{id}Expect: 100-Continue
Result codes:417 (Expectation Failed) // If service rejects request100 (Continue) // If service accepts request
HTTP Success Status Codes200OK201Created 202Accepted204No Content206Partial Content
HTTP Redirection Status Codes300Multiple Choices301Moved Permanently 302Found (Temporary Redirection)
HTTP Error Status Codes400Bad Request401Unauthorized 403Forbidden404Resource not found405Method not allowed408Request timeout409Conflict413Request entity too large415Unsupported media type
HTTP Server Error Status Codes500Internal Server Error501Not Implemented 503Service Unavailable505HTTP version not supported
REST WeaknessesConfusion (high REST vs. low REST)Is it really 4 verbs? (HTTP 1.1. has 8 verbs: HEAD, GET, POST, PUT, DELETE, TRACE, OPTIONS, and CONNECT)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)Cannot deliver enterprise-style -ilities beyond HTTP/SSLChallenging to identify and locate resources appropriately in all applicationsApparent lack of standards (other than URI, HTTP, XML, MIME, HTML)Semantics/Syntax description very informal (user/human oriented)
WADLWADL (Web Application Description Language)Not a widely used as WSDLMy opinion: overkillMost REST services are self-documented or have a textual description
WADL Example
Bob Dylan USA Columbia 10.90 1985
Bonnie Tyler UK CBS Records 9.90 1988
TitleArtistCountryCompanyPriceYearEmpire BurlesqueBob DylanUSAColumbia10.901985Hide your heartBonnie TylerUKCBS Records9.901988
More Info.Fiddler Web Proxy Tool (http://fiddler2.com/fiddler2/ )WCF ReST Starter Kit (http://msdn.microsoft.com/en-us/netframework/cc950529.aspx)PluralSight Screencast Aaron Skonnard (http://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Consuming-REST-services-with-HttpClient/)