SlideShare a Scribd company logo
Communication Protocols and Web Services Created by Omer Katz, 2010 Omer Katz © Some Rights Reserved
Structure of a standard networkingstack for the Web
Common serialization formats JSON Natively supported within JavaScript Capable of referencing other records by convention Human readable format Lightweight Easy to parse Uses JSON-Schema to validate itself Key-Value based syntax XML JavaScript exposes a proprietary DOM API Human readable format for hierarchal data Hard to parse Consumes more memory than JSON Supports XSLT and XPath Uses XML-Schema or DTD to validate itself Markup based syntax
What is a web service? A web service is typically an application programming interface (API) or Web API that is accessed via Hypertext Transfer Protocol (HTTP) and executed on a remote system, hosting the requested service. Web services do not provide the user with a GUI. Web services instead share business logic, data and processes through a programmatic interface across a network.  Developers can then add the Web service to a GUI (such as a Web page or an executable program) to offer specific functionality to users.
Web services communication protocols RPC XML-RPC HTTP Bound JSON-RPC SMD – Service Mapping Description JSONP Allows cross domain Ajax requests SOA SOAP XML Based Strongly typed WSDL dependant REST Stateless Cacheable Code On Demand Client and Server are unaware of each other’s state Layered System Uniform Interface Service may be described through SMD, WSDL, WADL or not at all
What is RPC? Remote Procedure Call. Allows to access server-side/inter-process operations from a client through a well-defined protocol. Examples: COBRA, XML-RPC, JSON-RPC, DCOM, RMI Client is tightly coupled with the server
JSON-RPC Request/Response model Request Notification Response Error Batch operations Advantages Lightweight JSON-Schemas can be extended to validate specific message Not bound to HTTP by the specification, but might be used with it Can be natively serialized from within JavaScript Service discovery can be achieved through SMD or WADL Disadvantages Procedural The web service's methods grow linearly with the number of client request types Not bound to a URI Conclusion Fits for low resources environment (embedded devices) Does not fit for rapidly growing web services Does not fit for web services operating on many entities unless the web service is an HTTP service
JSON-RPC Examples A Notification: {     ”jsonrpc”: ”2.0”,     ”method”: ”update”,     ”params”: [1,2,3,4,5] }
JSON-RPC Examples A Request {     ”jsonrpc”: ”2.0”,     ”method”: ”subtract”,     ”params”: {                    ”subtrahend”: 23,                    ”minuend”: 42                },     ”id”: 3 }
JSON-RPC Examples An Error: { 	”jsonrpc”: ”2.0”, 	”error”: { 			”code”: -32601,  			”message”: ”Procedure not found.” 		        }, 	”id”: ”1” }
JSON-RPC Examples Batch Request: [{ 		”jsonrpc”: ”2.0”,  		”method”: ”sum”, 		”params”: [1,2,4], 		”id”: ”1” 	},{ 		”jsonrpc”: ”2.0”, 		”method”: ”notify_hello”, 		”params”: [7] 	},{ 		”jsonrpc”: ”2.0”, 		”method”: ”subtract”, 		”params”: [42,23], 		”id”: ”2” 	} ]
JSON-RPC Examples Batch Response: [ 	{      ”jsonrpc”:”2.0”,      ”result”:7,      ”id”:”1” }, {      ”jsonrpc”:”2.0”,      ”result”:19,      ”id”:”2    	},{      ”jsonrpc”:”2.0”,      ”error”:{         ”code”:-32601,         ”message”:” Procedure not found.”      },      ”id”:”5” 	}, ]
XML-RPC Request/Response model Request Response Error Advantages Bound to a URI Can represent hierarchical data in a readable way XSLT & XPath Can be validated through XML-Schema or DTD Disadvantages Procedural The web service's methods grow linearly with the number of client request types Bound to HTTP Only appropriate for the web Hard to parse Heavy payload Consumes a lot of memory No bulk operations Conclusion Does not fit for rapidly growing web services Does not fit for embedded devices Fits to represent hierarchical data
XML-RPC Examples Request:  <?xml version=”1.0”?><methodCall> 			<methodName>examples.getStateName</methodName>            <params>                <param>                    <value>                        <i4>40</i4>                    </value>                </param>            </params></methodCall>
XML-RPC Examples Response: <?xml version=”1.0”?>    <methodResponse>        <params><param>                <value>                    <string>South Dakota</string>                </value>            </param>        </params>    </methodResponse>
XML-RPC Examples Error: <?xml version=”1.0”?>    <methodResponse>        <fault>            <value>                <struct>                    <member><name>faultCode</name>                        <value><int>4</int></value>                    </member>                    <member>                        <name>faultString</name>                        <value><string>Too many parameters.</string></value>                    </member>                </struct>            </value>    </fault></methodResponse>
What is SOA? Service Oriented Architecture. Allows to access server-side from a client through a well-defined protocol. Examples: SOAP, REST, SOAPjr Client does not have to be tightly coupled with the server. Unlike RPC based web services which usually are not discoverable there is a way to discover services in SOA based web service.
Service Description Standards WSDL Web Services Description Language Well known Verbose Uses XML Not human readable Used by WCF Feels natural for SOAP services Endorsed by Microsoft WSDL 1.1 supports only GET and POST requests
Service Description Standards - Continued WADL Web Application Description Language Not very well known A bit less verbose than WSDL Uses XML A bit more human readable Used by Java Feels natural for REST Services Endorsed by Sun Microsystems
Service Description Standards - Continued SMD Service Mapping Description  Working Draft status Less verbose Uses JSON Human readable Used by the Dojo Toolkit Not stable Endorsed by Sitepen and The Dojo Foundation
WSDL Example <description> <types>    <schema>        <element name=”myMethod”>            <complexType>                <sequence>                    <element name=”x” type=”xsd:int”/>                    <element name=”y” type=”xsd:float”/>                </sequence>            </complexType>        </element>        <element name=”myMethodResponse”>            <complexType/>        </element>    </schema></types>…
WSDL Example   <message name=”myMethodRequest”>    <part name=”parameters” element=”myMethod”/></message><message name=”empty”>    <part name=”parameters” element=”myMethodResponse”/></message><portTypename=”PT”>    <operation name=”myMethod”>        <input message=”myMethodRequest”/>        <output message=”empty”/>    </operation></portType> Hold your horses, there’s more…
WSDL Example       <binding interface=”...”>        <!-- The binding of a protocol to an interface, same structure              as the interface element -->     </binding>     <service interface=”...”>        <!-- Defines the actual addresses of the bindings, as in 1.1,              but now ”ports” are called ”endpoints” -->        <endpoint binding=”...” address=”...”/>     </service></description> And it goes on and on… I actually tried to keep it short.
Have I already mentioned that WSDL is verbose?
SMD Example { 	target:”/jsonrpc”, // this defines the URL to connect for the services transport:”POST”, // We will use POST as the transport envelope:”JSON-RPC-1.2”, // We will use JSON-RPC SMDVersion:”2.0”, services: {   add : { // define a service to add two numbers   parameters: [     {name:”a”,type:”number”}, // define the two parameters     {name:”b”,type:”number”}],   returns:{”type”:”number”} }, foo : {   // nothing is required to be defined, all definitions are optional.   //This service has nothing defined so it can take any parameters   //and return any value }, getNews : {   // we can redefine the target, transport, and envelope for specific services   target: ”/newsSearch”,   transport: ”GET”,   envelope: ”URL”,   parameters:[ { name: ”query”, type: ”string”, optional: false, default: ”” } ],   returns:{type:”array”} } }
But that’s not even a standard yet
WADL Example <application xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance      xsi:schemaLocation=http://research.sun.com/wadl/2006/10 wadl.xsd      xmlns:xsd=http://www.w3.org/2001/XMLSchema      xmlns:ex=http://www.example.org/types      xmlns=http://research.sun.com/wadl/2006/10>      <grammars>        <include href=ticker.xsd/>      </grammars>…
WADL Example <resources base=http://www.example.org/services/>         <resource path=getStockQuote>            <method name=GET>                 <request>                   <paramname=symbol style=query type=xsd:string/>                 </request>                <response>                   <representation mediaType=application/xml                        element=ex:quoteResponse/>                    <fault status=400 mediaType=application/xml                        element=ex:error/>                 </response>           </method>        </resource>    <! many other URIs>     </resources></application>
Looks a bit better, but it’s not widely adopted. So what do we do?
Service Discovery - Summery Use whatever your platform allows you (WSDL  for .NET, WADL  for JAVA and SMD for Dojo) Don’t allow service discovery – this may happen if:  You intend the web service to be used only internally. You are not using a tool to generate a proxy. You intend the web service to always be on a fixed IP Allow gradual service discovery Each call will expose different operations that are available Occasionally adds an unnecessary  overhead Can be solved using a parameter in the request to turn off and on gradual discovery Only exposes a part of the service that is related to the call
Service Discovery – WS-Discovery Web Services Dynamic Discovery A multicast discovery protocol that allows to locate web services over local network Uses web services standards like SOAP
SOAP Simple Object Access Protocol Message model: Request Response Error Advantages: Type safe WCF support feels more natural More appropriate for event driven use cases Services are discoverable Can carry any kind of data Disadvantages: Verbose WSDL Heavy payload, especially over HTTP Does not fit for streaming HTTP already knows how to handle requests/responses Accessing from a non-WCF client is nearly impossible Uses XML for the envelope, which makes the possibility to send any kind of data pretty much obsolete Conclusion Major pain in the ass
SOAP Example SOAP Request POST /InStock HTTP/1.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version=”1.0”?><soap:Envelopexmlns:soap=”http://www.w3.org/2001/12/soap-envelope” soap:encodingStyle=”http://www.w3.org/2001/12/soap-encoding”><soap:Bodyxmlns:m=”http://www.example.org/stock”>  		<m:GetStockPrice>    			<m:StockName>IBM</m:StockName>  		</m:GetStockPrice>	</soap:Body></soap:Envelope>
SOAP Example SOAP Response HTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version=”1.0”?><soap:Envelopexmlns:soap=”http://www.w3.org/2001/12/soap-envelope” soap:encodingStyle=”http://www.w3.org/2001/12/soap-encoding”>	<soap:Bodyxmlns:m=”http://www.example.org/stock”>  		<m:GetStockPriceResponse>    			<m:Price>34.5</m:Price>  	</m:GetStockPriceResponse>	</soap:Body></soap:Envelope>
Oh dear, take this abomination away
REST Representational State Transfer Constrains Stateless Uniform Interface Layered System Cacheable Code On Demand (Optional) Guiding principles Identification of resources Manipulation of resources through these representations Self-descriptive messages Hypermedia As The Engine Of Application State (HATEOAS)
REST is an architecture, not a standard. This means we relay on whatever application protocol we have to use.
REST is not bound to HTTP but feels natural with HTTP
REST – Web Services A RESTful web service is implemented over HTTP URI – Unique Resource Identifier Provides unified interface to access resources. /Foos/ - A collection of resources /Foos/[Identifier]/ - An object instance inside a collection Uses HTTP Verbs GET Used to get content, no side effects are guaranteed POST Used to update content PUT Used to create/replace content DELETE Used to delete content OPTIONS HEAD Discoverable through OPTIONS and HEAD Verbs Allows request to refer to different representation through MIME-types Responds with HTTP Status Codes
Hands On – A Simple RESTful Web Service using ASP.NET MVC We’re going to write a simple blog application Why ASP.NET MVC? Easy to implement Appropriate for small services What are our entities? A Post A Tag A Comment A User Both tags and comments entities are sub-entities of a post Both posts and comments entities are sub-entities of a user
Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme: To represent a resource collection of posts: /Posts/ To represent a specific post resource: /Posts/[id]/ To represent a resource collection of comments of a specific post resource: /Posts/[id]/Comments/ To represent a specific comment resource of a specific post resource: /Posts/[id]/Comments/[commentId] Well, you got the idea, right? How to implement: Go to your Global.asax file Define the routes Use constrains to avoid routes clashes Use constrains to define allowed HTTP Verbs
Hands On – A Simple RESTful Web Service using ASP.NET MVC Implementing the URI Scheme: publicstaticvoidRegisterRoutes(RouteCollection routes) {  // … routes.MapRoute(”DeleteComment”, ”Comments/{commentId}/”, new { controller = ”Comments”, action = ”Delete” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”DELETE”) }); routes.MapRoute(”EditComment”, ”Comments/{commentId}/”, new { controller = ”Comments”, action = ”Edit” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”PUT”) });    routes.MapRoute(”AddPostComment”, ”Posts/{postId}/Comments/”, new { controller = ”Comments”, action = ”Add” }, new { postId = @”+”, httpMethod = newHttpMethodConstraint(”POST”) });  routes.MapRoute(”PostComment”, ”Posts/{postId}/Comments/{commentId}/”, new { controller = ”Comments”, action = ”PostComment” }, new { postId = @”+”, commentId = @”+”, httpMethod = newHttpMethodConstraint(”GET”) });  routes.MapRoute(”PostComments”, ”Posts/{postId}/Comments/”, new { controller = ”Comments”, action = ”PostComments” }, new { postId = @”+”, httpMethod = newHttpMethodConstraint(”GET”) }); routes.MapRoute(”Comment”, ”Comments/{commentId}”, new { controller = ”Comments”, action = ”Comment” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”GET”) });  routes.MapRoute(”UserComments”, ”Users/{user}/Comments/”, new { controller = ”Comments”, action = ”UserComments” }, new { user = @”^[a-zA-Z0-9_]*$”, httpMethod = newHttpMethodConstraint(”GET”) });  routes.MapRoute(”UserComment”, ”Users/{user}/Comments/{commentId}/”,  new { controller = ”Comments”, action = ”UserComment” },  		  new { user = @”^[a-zA-Z0-9_]*$”, httpMethod = newHttpMethodConstraint(”GET”) }); // …}
Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme - Explained: Defines a route that maps to an action that allows to delete a comment commentId is limited to integral values (for more information, read about Regular Expressions) You can reach to this action only by a DELETE request publicstaticvoidRegisterRoutes(RouteCollection routes) {  // … routes.MapRoute(”DeleteComment”, ”Comments/{commentId}/”, new { controller = ”Comments”, action = ”Delete” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”DELETE”) }); // …}
Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme - Explained: Defines a route that maps to an action that allows to edit a comment commentId is limited to integral values You can reach to this action only by a PUT request Why are we using PUT instead of POST? The Comments/{commentId}/ URI refers to a specific item in a collection, since we are not sending only what is updated in our request we prefer to replace the resource instead of updating it publicstaticvoidRegisterRoutes(RouteCollection routes) {  // … routes.MapRoute(”EditComment”, ”Comments/{commentId}/”, new { controller = ”Comments”, action = ”Edit” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”PUT”) });  // …}
Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme - Explained: Defines a route that maps to an action that allows to add a comment to a post postId is limited to integral values You can reach to this action only by a POST request Why are we using POST instead of PUT? The Posts/{postId}/Comments/ URI refers to a collection, PUT will replace all of our existing comments with a new one POST only updates a resource, so a new comment is added to our existing comments collection publicstaticvoidRegisterRoutes(RouteCollection routes) {  // … routes.MapRoute(”AddPostComment”, ”Posts/{postId}/Comments/”, new { controller = ”Comments”, action = ”Add” }, new { postId = @”+”, httpMethod = newHttpMethodConstraint(”POST”) });  // …}
Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme - Explained: Those are the routes we are familiar with, the ones that use GET requests and most of the time return HTML In this example, this route maps to an action that allows us to access a specific comment on a post publicstaticvoidRegisterRoutes(RouteCollection routes) {  // …  routes.MapRoute(”PostComment”, ”Posts/{postId}/Comments/{commentId}/”, new { controller = ”Comments”, action = ”PostComment” }, new { postId = @”+”, commentId = @”+”, httpMethod = newHttpMethodConstraint(”GET”) }); // …}
Hands On – A Simple RESTful Web Service using ASP.NET MVC The comments controller: Now that our routes are defined we know what actions we need to implement All actions should use valid HTTP Status Codes All actions must be able to represent themselves in different formats (JSON, XML, HTML, RSS etc.) How to implement: Create a new controller called CommentsController Follow your routing scheme and create the needed actions Create a new action result decorator that allows you to select the HTTP Status code Use attributes to define allowed content types and HTTP Verbs
Hands On – A Simple RESTful Web Service using ASP.NET MVC Implementing the comments controller: publicclassCommentsController : Controller {         // …        [AcceptVerbs(HttpVerbs.Delete)] // Or [HttpDelete] if you are using MVC 2 and above publicActionResult Delete(intcommentId)         {             	// Delete operation occurs here returnnewHttpResponseCodeActionResultDecorator(204); // 204 No content }         [AcceptVerbs(HttpVerbs.Post)] // Or [HttpPost] if you are using MVC 2 and above publicActionResult Add(intpostId)         { 	        // Create a new comment that belongs to a post with a post Id of postIdreturnJson(new {CommentId = newCommentId}) ;         }         [AcceptVerbs(HttpVerbs.Put)] // Or [HttpPut] if you are using MVC 2 and above publicActionResult Add(intcommentId)         {            	// Create a new comment that belongs to a post with a post Id of postIdreturnnewHttpResponseCodeActionResultDecorator(201, Json(new {CommentId = newCommentId}) ); // 201 - Created }         // …}
Hands On – A Simple RESTful Web Service using ASP.NET MVC Implementing the HttpResponseCodeActionResultDecorator: publicclassHttpResponseCodeActionResultDecorator : ActionResult{         privatereadonlyintstatusCode;         privatereadonlyActionResultactionResult;         publicHttpResponseCodeActionResultDecorator(intstatusCode)         {             this.statusCode = statusCode;         }         publicHttpResponseCodeActionResultDecorator(intstatusCode, ActionResultactionResult)             : this(statusCode)         {             this.actionResult = actionResult;         }         publicoverridevoidExecuteResult(ControllerContext context)         {             context.HttpContext.Response.StatusCode = statusCode; if(actionResult != null)  	            actionResult.ExecuteResult(context);         } }
Hands On – A Simple RESTful Web Service using ASP.NET MVC Resources with multiple representations: Our list of posts should be representable through RSS and Atom feeds but also display them as HTML. An HTTP request containing an Accept header with a value other than application/rss+xml, application/atom+xml, text/html or application/xhtml+xml will return the HTTP response code “406 Not Acceptable”. The implementation is not trivial An example of an implementation can be seen here: http://aleembawany.com/2009/03/27/aspnet-mvc-create-easy-rest-api-with-json-and-xmlhowever it does not conform to HTTP due to the fact that it will either return 404 or the default view. How to implement: Create an ActionResult class that inspects the request’s Accept header and executes the requested ActionResult or return 406 Not Acceptable
Hands On – A Simple RESTful Web Service using ASP.NET MVC Implementing the AcceptTypeResult: publicclassAcceptTypeResult : ActionResult{         privatereadonlyint?successStatusCode; 	private readonly object result;         publicAcceptTypeResult(objectresult)         {            this.result = result;        }         publicAcceptTypeResult(intsuccessStatusCode, object result)          : this(result)         {            this.successStatusCode = successStatusCode;        }        publicoverridevoidExecuteResult(ControllerContext context)         { var request = context.HttpContext.Request;             context.HttpContext.Response.StatusCode = successStatusCode ?? 200; if (request.AcceptTypes.Contains(“application/rss+xml”)) Rss(result).ExecuteResult(context); else if (request.AcceptTypes.Contains(“application/atom+xml”)) Atom(result).ExecuteResult(context); else if (request.AcceptTypes.Contains(“application/xhtml+xml”) || request.AcceptTypes.Contains(“text/html”)) View(result).ExecuteResult(context); else             context.HttpContext.Response.StatusCode= 406;        } }
Bibliography http://www.infoq.com/articles/webber-rest-workflow http://www.infoq.com/articles/mark-baker-hypermedia http://barelyenough.org/blog/2007/05/hypermedia-as-the-engine-of-application-state/ http://third-bit.com/blog/archives/1746.html http://www.learnxpress.com/create-restful-wcf-service-api-step-by-step-guide.html http://www.infoq.com/articles/rest-soap-when-to-use-each http://www.prescod.net/rest/ http://www.prescod.net/rest/rest_vs_soap_overview/ http://www.devx.com/DevX/Article/8155 http://tomayko.com/writings/rest-to-my-wife http://en.wikipedia.org/wiki/Representational_State_Transfer http://en.wikipedia.org/wiki/HATEOAS http://en.wikipedia.org/wiki/SOAP http://en.wikipedia.org/wiki/SOA http://en.wikipedia.org/wiki/Web_Application_Description_Language http://en.wikipedia.org/wiki/WSDL http://en.wikipedia.org/wiki/JSON-RPC http://en.wikipedia.org/wiki/XML-RPC http://www.sitepen.com/blog/2008/03/19/pluggable-web-services-with-smd/
For further reading http://jcalcote.wordpress.com/2009/08/10/restful-authentication/ http://jcalcote.wordpress.com/2009/08/06/restful-transactions/ http://www.artima.com/lejava/articles/why_put_and_delete.html http://www.markbaker.ca/2002/08/HowContainersWork/ http://www.w3.org/Protocols/rfc2616/rfc2616.html http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-vs-put/ http://blog.whatfettle.com/2006/08/14/so-which-crud-operation-is-http-post/ http://cafe.elharo.com/web/why-rest-failed/ http://en.wikipedia.org/wiki/Windows_Communication_Foundation
Thank you for listening!

More Related Content

What's hot

Wsdl
WsdlWsdl
Http request and http response
Http request and http responseHttp request and http response
Http request and http response
Nuha Noor
 
firewall and its types
firewall and its typesfirewall and its types
firewall and its types
Mohammed Maajidh
 
OAuth 2
OAuth 2OAuth 2
OAuth 2
ChrisWood262
 
HTTP
HTTPHTTP
DEF CON 27 - BEN SADEGHIPOUR - owning the clout through ssrf and pdf generators
DEF CON 27 - BEN SADEGHIPOUR  - owning the clout through ssrf and pdf generatorsDEF CON 27 - BEN SADEGHIPOUR  - owning the clout through ssrf and pdf generators
DEF CON 27 - BEN SADEGHIPOUR - owning the clout through ssrf and pdf generators
Felipe Prado
 
Introduction to WebSockets Presentation
Introduction to WebSockets PresentationIntroduction to WebSockets Presentation
Introduction to WebSockets Presentation
Julien LaPointe
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
Chetan Gadodia
 
Virtual private network, vpn presentation
Virtual private network, vpn presentationVirtual private network, vpn presentation
Virtual private network, vpn presentation
Amjad Bhutto
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
Stormpath
 
SVG - Scalable Vector Graphics
SVG - Scalable Vector GraphicsSVG - Scalable Vector Graphics
SVG - Scalable Vector Graphics
Shweta Sadawarte
 
WEB SECURITY.pdf
WEB SECURITY.pdfWEB SECURITY.pdf
WEB SECURITY.pdf
TENZING LHADON
 
Client Server models in JAVA
Client Server models in JAVAClient Server models in JAVA
Client Server models in JAVA
Tech_MX
 
Web Services
Web ServicesWeb Services
Web Services
Katrien Verbert
 
Http Introduction
Http IntroductionHttp Introduction
Http Introduction
Akshay Dhole
 
Rest API
Rest APIRest API
Rest API
Phil Aylesworth
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
Patrick Savalle
 
Http headers
Http headersHttp headers
Http headers
Judy Ngure
 
Real Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioReal Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.io
Mindfire Solutions
 
HTTP & HTTPS
HTTP & HTTPSHTTP & HTTPS
HTTP & HTTPS
NetProtocol Xpert
 

What's hot (20)

Wsdl
WsdlWsdl
Wsdl
 
Http request and http response
Http request and http responseHttp request and http response
Http request and http response
 
firewall and its types
firewall and its typesfirewall and its types
firewall and its types
 
OAuth 2
OAuth 2OAuth 2
OAuth 2
 
HTTP
HTTPHTTP
HTTP
 
DEF CON 27 - BEN SADEGHIPOUR - owning the clout through ssrf and pdf generators
DEF CON 27 - BEN SADEGHIPOUR  - owning the clout through ssrf and pdf generatorsDEF CON 27 - BEN SADEGHIPOUR  - owning the clout through ssrf and pdf generators
DEF CON 27 - BEN SADEGHIPOUR - owning the clout through ssrf and pdf generators
 
Introduction to WebSockets Presentation
Introduction to WebSockets PresentationIntroduction to WebSockets Presentation
Introduction to WebSockets Presentation
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 
Virtual private network, vpn presentation
Virtual private network, vpn presentationVirtual private network, vpn presentation
Virtual private network, vpn presentation
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
 
SVG - Scalable Vector Graphics
SVG - Scalable Vector GraphicsSVG - Scalable Vector Graphics
SVG - Scalable Vector Graphics
 
WEB SECURITY.pdf
WEB SECURITY.pdfWEB SECURITY.pdf
WEB SECURITY.pdf
 
Client Server models in JAVA
Client Server models in JAVAClient Server models in JAVA
Client Server models in JAVA
 
Web Services
Web ServicesWeb Services
Web Services
 
Http Introduction
Http IntroductionHttp Introduction
Http Introduction
 
Rest API
Rest APIRest API
Rest API
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Http headers
Http headersHttp headers
Http headers
 
Real Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioReal Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.io
 
HTTP & HTTPS
HTTP & HTTPSHTTP & HTTPS
HTTP & HTTPS
 

Viewers also liked

Services of internet
Services of internetServices of internet
Services of internet
niraj singh
 
External Data Access with jQuery
External Data Access with jQueryExternal Data Access with jQuery
External Data Access with jQuery
Doncho Minkov
 
SRS for Hospital Management System
SRS for Hospital Management SystemSRS for Hospital Management System
SRS for Hospital Management System
kataria Arvind
 
Romansjosye
RomansjosyeRomansjosye
Romansjosye
FranJLte
 
The Forces of Disruptive Innovation for Startups
The Forces of Disruptive Innovation for StartupsThe Forces of Disruptive Innovation for Startups
The Forces of Disruptive Innovation for Startups
Ja-Nae Duane
 
Ldap a debian lenny pas a pas
Ldap a debian lenny pas a pasLdap a debian lenny pas a pas
Ldap a debian lenny pas a pas
Jordi Clopés Esteban
 
Collin powell 171
Collin powell 171Collin powell 171
Collin powell 171
chhap
 
O'leary cell.ppt
O'leary cell.pptO'leary cell.ppt
O'leary cell.ppt
olearya
 
Katrin anacker tiaa_cref_submission
Katrin anacker tiaa_cref_submissionKatrin anacker tiaa_cref_submission
Katrin anacker tiaa_cref_submission
kanacker
 
San francisco native food
San francisco native foodSan francisco native food
San francisco native food
Mari Cheung
 
Presentation re:new
Presentation re:newPresentation re:new
Presentation re:new
Pes Pse
 
Biggest loser
Biggest loserBiggest loser
Biggest loser
seminoleit
 
Czy opłaciło się nam wejść do unii europejskiej
Czy opłaciło się nam wejść do unii europejskiejCzy opłaciło się nam wejść do unii europejskiej
Czy opłaciło się nam wejść do unii europejskiejsknsz
 
Ettkanne 13.sept.2013
Ettkanne 13.sept.2013Ettkanne 13.sept.2013
Ettkanne 13.sept.2013Margus Ots
 
Palmer warsaw school of economics presentation
Palmer warsaw school of economics presentationPalmer warsaw school of economics presentation
Palmer warsaw school of economics presentation
sknsz
 
Why Average Response Time is not a right measure of your web application's pe...
Why Average Response Time is not a right measure of your web application's pe...Why Average Response Time is not a right measure of your web application's pe...
Why Average Response Time is not a right measure of your web application's pe...
vodQA
 
Key note Manish and Deepa
Key note Manish and DeepaKey note Manish and Deepa
Key note Manish and Deepa
vodQA
 
2012 Corporate Info
2012 Corporate Info2012 Corporate Info
2012 Corporate Info
knowledgewire
 

Viewers also liked (20)

Services of internet
Services of internetServices of internet
Services of internet
 
External Data Access with jQuery
External Data Access with jQueryExternal Data Access with jQuery
External Data Access with jQuery
 
SRS for Hospital Management System
SRS for Hospital Management SystemSRS for Hospital Management System
SRS for Hospital Management System
 
Romansjosye
RomansjosyeRomansjosye
Romansjosye
 
The Forces of Disruptive Innovation for Startups
The Forces of Disruptive Innovation for StartupsThe Forces of Disruptive Innovation for Startups
The Forces of Disruptive Innovation for Startups
 
Ldap a debian lenny pas a pas
Ldap a debian lenny pas a pasLdap a debian lenny pas a pas
Ldap a debian lenny pas a pas
 
Collin powell 171
Collin powell 171Collin powell 171
Collin powell 171
 
3 d tv
3 d tv3 d tv
3 d tv
 
O'leary cell.ppt
O'leary cell.pptO'leary cell.ppt
O'leary cell.ppt
 
Katrin anacker tiaa_cref_submission
Katrin anacker tiaa_cref_submissionKatrin anacker tiaa_cref_submission
Katrin anacker tiaa_cref_submission
 
San francisco native food
San francisco native foodSan francisco native food
San francisco native food
 
Presentation re:new
Presentation re:newPresentation re:new
Presentation re:new
 
Biggest loser
Biggest loserBiggest loser
Biggest loser
 
Czy opłaciło się nam wejść do unii europejskiej
Czy opłaciło się nam wejść do unii europejskiejCzy opłaciło się nam wejść do unii europejskiej
Czy opłaciło się nam wejść do unii europejskiej
 
Ettkanne 13.sept.2013
Ettkanne 13.sept.2013Ettkanne 13.sept.2013
Ettkanne 13.sept.2013
 
Palmer warsaw school of economics presentation
Palmer warsaw school of economics presentationPalmer warsaw school of economics presentation
Palmer warsaw school of economics presentation
 
งานฉันในอดีต
งานฉันในอดีตงานฉันในอดีต
งานฉันในอดีต
 
Why Average Response Time is not a right measure of your web application's pe...
Why Average Response Time is not a right measure of your web application's pe...Why Average Response Time is not a right measure of your web application's pe...
Why Average Response Time is not a right measure of your web application's pe...
 
Key note Manish and Deepa
Key note Manish and DeepaKey note Manish and Deepa
Key note Manish and Deepa
 
2012 Corporate Info
2012 Corporate Info2012 Corporate Info
2012 Corporate Info
 

Similar to Communication Protocols And Web Services

SOA and web services
SOA and web servicesSOA and web services
SOA and web services
Sreekanth Narayanan
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web services
Neil Ghosh
 
Web Services
Web ServicesWeb Services
Web Services
Gaurav Tyagi
 
Web Services
Web ServicesWeb Services
Web Services
Gaurav Tyagi
 
Restful web services
Restful web servicesRestful web services
Restful web services
MD Sayem Ahmed
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
jkljklj
jkljkljjkljklj
jkljklj
hoefo
 
Bottom-Line Web Services
Bottom-Line Web ServicesBottom-Line Web Services
Bottom-Line Web Services
Mohammed Makhlouf
 
complete web service1.ppt
complete web service1.pptcomplete web service1.ppt
complete web service1.ppt
Dr.Saranya K.G
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAM
Woody Pewitt
 
Mobility Information Series - Webservice Architecture Comparison by RapidValue
Mobility Information Series - Webservice Architecture Comparison by RapidValueMobility Information Series - Webservice Architecture Comparison by RapidValue
Mobility Information Series - Webservice Architecture Comparison by RapidValue
RapidValue
 
Web services for developer
Web services for developerWeb services for developer
Web services for developer
Rafiq Ahmed
 
Rest web service
Rest web serviceRest web service
Rest web service
Hamid Ghorbani
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
Carol McDonald
 
REST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and LiesREST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and Lies
Paul Fremantle
 
SOAP WEB TECHNOLOGIES
SOAP WEB TECHNOLOGIESSOAP WEB TECHNOLOGIES
SOAP WEB TECHNOLOGIES
tamilmozhiyaltamilmo
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
Compare Infobase Limited
 
RIA and Ajax
RIA and AjaxRIA and Ajax
RIA and Ajax
Schubert Gomes
 
Semantic Web Servers
Semantic Web ServersSemantic Web Servers
Semantic Web Servers
webhostingguy
 
Ipso smart object seminar
Ipso smart object seminarIpso smart object seminar
Ipso smart object seminar
Michael Koster
 

Similar to Communication Protocols And Web Services (20)

SOA and web services
SOA and web servicesSOA and web services
SOA and web services
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web services
 
Web Services
Web ServicesWeb Services
Web Services
 
Web Services
Web ServicesWeb Services
Web Services
 
Restful web services
Restful web servicesRestful web services
Restful web services
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
jkljklj
jkljkljjkljklj
jkljklj
 
Bottom-Line Web Services
Bottom-Line Web ServicesBottom-Line Web Services
Bottom-Line Web Services
 
complete web service1.ppt
complete web service1.pptcomplete web service1.ppt
complete web service1.ppt
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAM
 
Mobility Information Series - Webservice Architecture Comparison by RapidValue
Mobility Information Series - Webservice Architecture Comparison by RapidValueMobility Information Series - Webservice Architecture Comparison by RapidValue
Mobility Information Series - Webservice Architecture Comparison by RapidValue
 
Web services for developer
Web services for developerWeb services for developer
Web services for developer
 
Rest web service
Rest web serviceRest web service
Rest web service
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
REST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and LiesREST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and Lies
 
SOAP WEB TECHNOLOGIES
SOAP WEB TECHNOLOGIESSOAP WEB TECHNOLOGIES
SOAP WEB TECHNOLOGIES
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
 
RIA and Ajax
RIA and AjaxRIA and Ajax
RIA and Ajax
 
Semantic Web Servers
Semantic Web ServersSemantic Web Servers
Semantic Web Servers
 
Ipso smart object seminar
Ipso smart object seminarIpso smart object seminar
Ipso smart object seminar
 

Recently uploaded

Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 

Recently uploaded (20)

Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Artificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic WarfareArtificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic Warfare
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 

Communication Protocols And Web Services

  • 1. Communication Protocols and Web Services Created by Omer Katz, 2010 Omer Katz © Some Rights Reserved
  • 2. Structure of a standard networkingstack for the Web
  • 3. Common serialization formats JSON Natively supported within JavaScript Capable of referencing other records by convention Human readable format Lightweight Easy to parse Uses JSON-Schema to validate itself Key-Value based syntax XML JavaScript exposes a proprietary DOM API Human readable format for hierarchal data Hard to parse Consumes more memory than JSON Supports XSLT and XPath Uses XML-Schema or DTD to validate itself Markup based syntax
  • 4. What is a web service? A web service is typically an application programming interface (API) or Web API that is accessed via Hypertext Transfer Protocol (HTTP) and executed on a remote system, hosting the requested service. Web services do not provide the user with a GUI. Web services instead share business logic, data and processes through a programmatic interface across a network. Developers can then add the Web service to a GUI (such as a Web page or an executable program) to offer specific functionality to users.
  • 5. Web services communication protocols RPC XML-RPC HTTP Bound JSON-RPC SMD – Service Mapping Description JSONP Allows cross domain Ajax requests SOA SOAP XML Based Strongly typed WSDL dependant REST Stateless Cacheable Code On Demand Client and Server are unaware of each other’s state Layered System Uniform Interface Service may be described through SMD, WSDL, WADL or not at all
  • 6. What is RPC? Remote Procedure Call. Allows to access server-side/inter-process operations from a client through a well-defined protocol. Examples: COBRA, XML-RPC, JSON-RPC, DCOM, RMI Client is tightly coupled with the server
  • 7. JSON-RPC Request/Response model Request Notification Response Error Batch operations Advantages Lightweight JSON-Schemas can be extended to validate specific message Not bound to HTTP by the specification, but might be used with it Can be natively serialized from within JavaScript Service discovery can be achieved through SMD or WADL Disadvantages Procedural The web service's methods grow linearly with the number of client request types Not bound to a URI Conclusion Fits for low resources environment (embedded devices) Does not fit for rapidly growing web services Does not fit for web services operating on many entities unless the web service is an HTTP service
  • 8. JSON-RPC Examples A Notification: {     ”jsonrpc”: ”2.0”,     ”method”: ”update”,     ”params”: [1,2,3,4,5] }
  • 9. JSON-RPC Examples A Request {     ”jsonrpc”: ”2.0”,     ”method”: ”subtract”,     ”params”: {                    ”subtrahend”: 23,                    ”minuend”: 42                },     ”id”: 3 }
  • 10. JSON-RPC Examples An Error: { ”jsonrpc”: ”2.0”, ”error”: { ”code”: -32601, ”message”: ”Procedure not found.” }, ”id”: ”1” }
  • 11. JSON-RPC Examples Batch Request: [{ ”jsonrpc”: ”2.0”, ”method”: ”sum”, ”params”: [1,2,4], ”id”: ”1” },{ ”jsonrpc”: ”2.0”, ”method”: ”notify_hello”, ”params”: [7] },{ ”jsonrpc”: ”2.0”, ”method”: ”subtract”, ”params”: [42,23], ”id”: ”2” } ]
  • 12. JSON-RPC Examples Batch Response: [ {      ”jsonrpc”:”2.0”,      ”result”:7,      ”id”:”1” }, {      ”jsonrpc”:”2.0”,      ”result”:19,      ”id”:”2     },{      ”jsonrpc”:”2.0”,      ”error”:{         ”code”:-32601,         ”message”:” Procedure not found.”      },      ”id”:”5” }, ]
  • 13. XML-RPC Request/Response model Request Response Error Advantages Bound to a URI Can represent hierarchical data in a readable way XSLT & XPath Can be validated through XML-Schema or DTD Disadvantages Procedural The web service's methods grow linearly with the number of client request types Bound to HTTP Only appropriate for the web Hard to parse Heavy payload Consumes a lot of memory No bulk operations Conclusion Does not fit for rapidly growing web services Does not fit for embedded devices Fits to represent hierarchical data
  • 14. XML-RPC Examples Request: <?xml version=”1.0”?><methodCall> <methodName>examples.getStateName</methodName>            <params>                <param>                    <value>                        <i4>40</i4>                    </value>                </param>            </params></methodCall>
  • 15. XML-RPC Examples Response: <?xml version=”1.0”?>    <methodResponse>        <params><param>                <value>                    <string>South Dakota</string>                </value>            </param>        </params>    </methodResponse>
  • 16. XML-RPC Examples Error: <?xml version=”1.0”?>    <methodResponse>        <fault>            <value>                <struct>                    <member><name>faultCode</name>                        <value><int>4</int></value>                    </member>                    <member>                        <name>faultString</name>                        <value><string>Too many parameters.</string></value>                    </member>                </struct>            </value>    </fault></methodResponse>
  • 17. What is SOA? Service Oriented Architecture. Allows to access server-side from a client through a well-defined protocol. Examples: SOAP, REST, SOAPjr Client does not have to be tightly coupled with the server. Unlike RPC based web services which usually are not discoverable there is a way to discover services in SOA based web service.
  • 18. Service Description Standards WSDL Web Services Description Language Well known Verbose Uses XML Not human readable Used by WCF Feels natural for SOAP services Endorsed by Microsoft WSDL 1.1 supports only GET and POST requests
  • 19. Service Description Standards - Continued WADL Web Application Description Language Not very well known A bit less verbose than WSDL Uses XML A bit more human readable Used by Java Feels natural for REST Services Endorsed by Sun Microsystems
  • 20. Service Description Standards - Continued SMD Service Mapping Description Working Draft status Less verbose Uses JSON Human readable Used by the Dojo Toolkit Not stable Endorsed by Sitepen and The Dojo Foundation
  • 21. WSDL Example <description> <types>    <schema>        <element name=”myMethod”>            <complexType>                <sequence>                    <element name=”x” type=”xsd:int”/>                    <element name=”y” type=”xsd:float”/>                </sequence>            </complexType>        </element>        <element name=”myMethodResponse”>            <complexType/>        </element>    </schema></types>…
  • 22. WSDL Example <message name=”myMethodRequest”>    <part name=”parameters” element=”myMethod”/></message><message name=”empty”>    <part name=”parameters” element=”myMethodResponse”/></message><portTypename=”PT”>    <operation name=”myMethod”>        <input message=”myMethodRequest”/>        <output message=”empty”/>    </operation></portType> Hold your horses, there’s more…
  • 23. WSDL Example <binding interface=”...”>        <!-- The binding of a protocol to an interface, same structure              as the interface element -->     </binding>     <service interface=”...”>        <!-- Defines the actual addresses of the bindings, as in 1.1,              but now ”ports” are called ”endpoints” -->        <endpoint binding=”...” address=”...”/>     </service></description> And it goes on and on… I actually tried to keep it short.
  • 24. Have I already mentioned that WSDL is verbose?
  • 25. SMD Example { target:”/jsonrpc”, // this defines the URL to connect for the services transport:”POST”, // We will use POST as the transport envelope:”JSON-RPC-1.2”, // We will use JSON-RPC SMDVersion:”2.0”, services: {   add : { // define a service to add two numbers   parameters: [     {name:”a”,type:”number”}, // define the two parameters     {name:”b”,type:”number”}],   returns:{”type”:”number”} }, foo : {   // nothing is required to be defined, all definitions are optional.   //This service has nothing defined so it can take any parameters   //and return any value }, getNews : {   // we can redefine the target, transport, and envelope for specific services   target: ”/newsSearch”,   transport: ”GET”,   envelope: ”URL”,   parameters:[ { name: ”query”, type: ”string”, optional: false, default: ”” } ],   returns:{type:”array”} } }
  • 26. But that’s not even a standard yet
  • 27. WADL Example <application xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance      xsi:schemaLocation=http://research.sun.com/wadl/2006/10 wadl.xsd      xmlns:xsd=http://www.w3.org/2001/XMLSchema      xmlns:ex=http://www.example.org/types      xmlns=http://research.sun.com/wadl/2006/10>      <grammars>        <include href=ticker.xsd/>      </grammars>…
  • 28. WADL Example <resources base=http://www.example.org/services/>         <resource path=getStockQuote>            <method name=GET>                 <request>                   <paramname=symbol style=query type=xsd:string/>                 </request>                <response>                   <representation mediaType=application/xml                        element=ex:quoteResponse/>                    <fault status=400 mediaType=application/xml                        element=ex:error/>                 </response>           </method>        </resource>    <! many other URIs>     </resources></application>
  • 29. Looks a bit better, but it’s not widely adopted. So what do we do?
  • 30. Service Discovery - Summery Use whatever your platform allows you (WSDL for .NET, WADL for JAVA and SMD for Dojo) Don’t allow service discovery – this may happen if: You intend the web service to be used only internally. You are not using a tool to generate a proxy. You intend the web service to always be on a fixed IP Allow gradual service discovery Each call will expose different operations that are available Occasionally adds an unnecessary overhead Can be solved using a parameter in the request to turn off and on gradual discovery Only exposes a part of the service that is related to the call
  • 31. Service Discovery – WS-Discovery Web Services Dynamic Discovery A multicast discovery protocol that allows to locate web services over local network Uses web services standards like SOAP
  • 32. SOAP Simple Object Access Protocol Message model: Request Response Error Advantages: Type safe WCF support feels more natural More appropriate for event driven use cases Services are discoverable Can carry any kind of data Disadvantages: Verbose WSDL Heavy payload, especially over HTTP Does not fit for streaming HTTP already knows how to handle requests/responses Accessing from a non-WCF client is nearly impossible Uses XML for the envelope, which makes the possibility to send any kind of data pretty much obsolete Conclusion Major pain in the ass
  • 33. SOAP Example SOAP Request POST /InStock HTTP/1.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version=”1.0”?><soap:Envelopexmlns:soap=”http://www.w3.org/2001/12/soap-envelope” soap:encodingStyle=”http://www.w3.org/2001/12/soap-encoding”><soap:Bodyxmlns:m=”http://www.example.org/stock”>  <m:GetStockPrice>    <m:StockName>IBM</m:StockName>  </m:GetStockPrice> </soap:Body></soap:Envelope>
  • 34. SOAP Example SOAP Response HTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version=”1.0”?><soap:Envelopexmlns:soap=”http://www.w3.org/2001/12/soap-envelope” soap:encodingStyle=”http://www.w3.org/2001/12/soap-encoding”> <soap:Bodyxmlns:m=”http://www.example.org/stock”>  <m:GetStockPriceResponse>    <m:Price>34.5</m:Price>  </m:GetStockPriceResponse> </soap:Body></soap:Envelope>
  • 35. Oh dear, take this abomination away
  • 36. REST Representational State Transfer Constrains Stateless Uniform Interface Layered System Cacheable Code On Demand (Optional) Guiding principles Identification of resources Manipulation of resources through these representations Self-descriptive messages Hypermedia As The Engine Of Application State (HATEOAS)
  • 37. REST is an architecture, not a standard. This means we relay on whatever application protocol we have to use.
  • 38. REST is not bound to HTTP but feels natural with HTTP
  • 39. REST – Web Services A RESTful web service is implemented over HTTP URI – Unique Resource Identifier Provides unified interface to access resources. /Foos/ - A collection of resources /Foos/[Identifier]/ - An object instance inside a collection Uses HTTP Verbs GET Used to get content, no side effects are guaranteed POST Used to update content PUT Used to create/replace content DELETE Used to delete content OPTIONS HEAD Discoverable through OPTIONS and HEAD Verbs Allows request to refer to different representation through MIME-types Responds with HTTP Status Codes
  • 40. Hands On – A Simple RESTful Web Service using ASP.NET MVC We’re going to write a simple blog application Why ASP.NET MVC? Easy to implement Appropriate for small services What are our entities? A Post A Tag A Comment A User Both tags and comments entities are sub-entities of a post Both posts and comments entities are sub-entities of a user
  • 41. Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme: To represent a resource collection of posts: /Posts/ To represent a specific post resource: /Posts/[id]/ To represent a resource collection of comments of a specific post resource: /Posts/[id]/Comments/ To represent a specific comment resource of a specific post resource: /Posts/[id]/Comments/[commentId] Well, you got the idea, right? How to implement: Go to your Global.asax file Define the routes Use constrains to avoid routes clashes Use constrains to define allowed HTTP Verbs
  • 42. Hands On – A Simple RESTful Web Service using ASP.NET MVC Implementing the URI Scheme: publicstaticvoidRegisterRoutes(RouteCollection routes) { // … routes.MapRoute(”DeleteComment”, ”Comments/{commentId}/”, new { controller = ”Comments”, action = ”Delete” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”DELETE”) }); routes.MapRoute(”EditComment”, ”Comments/{commentId}/”, new { controller = ”Comments”, action = ”Edit” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”PUT”) });  routes.MapRoute(”AddPostComment”, ”Posts/{postId}/Comments/”, new { controller = ”Comments”, action = ”Add” }, new { postId = @”+”, httpMethod = newHttpMethodConstraint(”POST”) });  routes.MapRoute(”PostComment”, ”Posts/{postId}/Comments/{commentId}/”, new { controller = ”Comments”, action = ”PostComment” }, new { postId = @”+”, commentId = @”+”, httpMethod = newHttpMethodConstraint(”GET”) });  routes.MapRoute(”PostComments”, ”Posts/{postId}/Comments/”, new { controller = ”Comments”, action = ”PostComments” }, new { postId = @”+”, httpMethod = newHttpMethodConstraint(”GET”) }); routes.MapRoute(”Comment”, ”Comments/{commentId}”, new { controller = ”Comments”, action = ”Comment” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”GET”) });  routes.MapRoute(”UserComments”, ”Users/{user}/Comments/”, new { controller = ”Comments”, action = ”UserComments” }, new { user = @”^[a-zA-Z0-9_]*$”, httpMethod = newHttpMethodConstraint(”GET”) });  routes.MapRoute(”UserComment”, ”Users/{user}/Comments/{commentId}/”, new { controller = ”Comments”, action = ”UserComment” },   new { user = @”^[a-zA-Z0-9_]*$”, httpMethod = newHttpMethodConstraint(”GET”) }); // …}
  • 43. Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme - Explained: Defines a route that maps to an action that allows to delete a comment commentId is limited to integral values (for more information, read about Regular Expressions) You can reach to this action only by a DELETE request publicstaticvoidRegisterRoutes(RouteCollection routes) { // … routes.MapRoute(”DeleteComment”, ”Comments/{commentId}/”, new { controller = ”Comments”, action = ”Delete” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”DELETE”) }); // …}
  • 44. Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme - Explained: Defines a route that maps to an action that allows to edit a comment commentId is limited to integral values You can reach to this action only by a PUT request Why are we using PUT instead of POST? The Comments/{commentId}/ URI refers to a specific item in a collection, since we are not sending only what is updated in our request we prefer to replace the resource instead of updating it publicstaticvoidRegisterRoutes(RouteCollection routes) { // … routes.MapRoute(”EditComment”, ”Comments/{commentId}/”, new { controller = ”Comments”, action = ”Edit” }, new { commentId = @”+”, httpMethod = newHttpMethodConstraint(”PUT”) }); // …}
  • 45. Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme - Explained: Defines a route that maps to an action that allows to add a comment to a post postId is limited to integral values You can reach to this action only by a POST request Why are we using POST instead of PUT? The Posts/{postId}/Comments/ URI refers to a collection, PUT will replace all of our existing comments with a new one POST only updates a resource, so a new comment is added to our existing comments collection publicstaticvoidRegisterRoutes(RouteCollection routes) { // … routes.MapRoute(”AddPostComment”, ”Posts/{postId}/Comments/”, new { controller = ”Comments”, action = ”Add” }, new { postId = @”+”, httpMethod = newHttpMethodConstraint(”POST”) }); // …}
  • 46. Hands On – A Simple RESTful Web Service using ASP.NET MVC The URI Scheme - Explained: Those are the routes we are familiar with, the ones that use GET requests and most of the time return HTML In this example, this route maps to an action that allows us to access a specific comment on a post publicstaticvoidRegisterRoutes(RouteCollection routes) { // …  routes.MapRoute(”PostComment”, ”Posts/{postId}/Comments/{commentId}/”, new { controller = ”Comments”, action = ”PostComment” }, new { postId = @”+”, commentId = @”+”, httpMethod = newHttpMethodConstraint(”GET”) }); // …}
  • 47. Hands On – A Simple RESTful Web Service using ASP.NET MVC The comments controller: Now that our routes are defined we know what actions we need to implement All actions should use valid HTTP Status Codes All actions must be able to represent themselves in different formats (JSON, XML, HTML, RSS etc.) How to implement: Create a new controller called CommentsController Follow your routing scheme and create the needed actions Create a new action result decorator that allows you to select the HTTP Status code Use attributes to define allowed content types and HTTP Verbs
  • 48. Hands On – A Simple RESTful Web Service using ASP.NET MVC Implementing the comments controller: publicclassCommentsController : Controller {         // …        [AcceptVerbs(HttpVerbs.Delete)] // Or [HttpDelete] if you are using MVC 2 and above publicActionResult Delete(intcommentId)         {              // Delete operation occurs here returnnewHttpResponseCodeActionResultDecorator(204); // 204 No content }         [AcceptVerbs(HttpVerbs.Post)] // Or [HttpPost] if you are using MVC 2 and above publicActionResult Add(intpostId)         {         // Create a new comment that belongs to a post with a post Id of postIdreturnJson(new {CommentId = newCommentId}) ;         }         [AcceptVerbs(HttpVerbs.Put)] // Or [HttpPut] if you are using MVC 2 and above publicActionResult Add(intcommentId)         {             // Create a new comment that belongs to a post with a post Id of postIdreturnnewHttpResponseCodeActionResultDecorator(201, Json(new {CommentId = newCommentId}) ); // 201 - Created }         // …}
  • 49. Hands On – A Simple RESTful Web Service using ASP.NET MVC Implementing the HttpResponseCodeActionResultDecorator: publicclassHttpResponseCodeActionResultDecorator : ActionResult{         privatereadonlyintstatusCode;         privatereadonlyActionResultactionResult;         publicHttpResponseCodeActionResultDecorator(intstatusCode)         {             this.statusCode = statusCode;         }         publicHttpResponseCodeActionResultDecorator(intstatusCode, ActionResultactionResult)             : this(statusCode)         {             this.actionResult = actionResult;         }         publicoverridevoidExecuteResult(ControllerContext context)         {             context.HttpContext.Response.StatusCode = statusCode; if(actionResult != null)             actionResult.ExecuteResult(context);         } }
  • 50. Hands On – A Simple RESTful Web Service using ASP.NET MVC Resources with multiple representations: Our list of posts should be representable through RSS and Atom feeds but also display them as HTML. An HTTP request containing an Accept header with a value other than application/rss+xml, application/atom+xml, text/html or application/xhtml+xml will return the HTTP response code “406 Not Acceptable”. The implementation is not trivial An example of an implementation can be seen here: http://aleembawany.com/2009/03/27/aspnet-mvc-create-easy-rest-api-with-json-and-xmlhowever it does not conform to HTTP due to the fact that it will either return 404 or the default view. How to implement: Create an ActionResult class that inspects the request’s Accept header and executes the requested ActionResult or return 406 Not Acceptable
  • 51. Hands On – A Simple RESTful Web Service using ASP.NET MVC Implementing the AcceptTypeResult: publicclassAcceptTypeResult : ActionResult{         privatereadonlyint?successStatusCode; private readonly object result;         publicAcceptTypeResult(objectresult)         {            this.result = result;        }         publicAcceptTypeResult(intsuccessStatusCode, object result) : this(result)         {            this.successStatusCode = successStatusCode;        }        publicoverridevoidExecuteResult(ControllerContext context)         { var request = context.HttpContext.Request;             context.HttpContext.Response.StatusCode = successStatusCode ?? 200; if (request.AcceptTypes.Contains(“application/rss+xml”)) Rss(result).ExecuteResult(context); else if (request.AcceptTypes.Contains(“application/atom+xml”)) Atom(result).ExecuteResult(context); else if (request.AcceptTypes.Contains(“application/xhtml+xml”) || request.AcceptTypes.Contains(“text/html”)) View(result).ExecuteResult(context); else             context.HttpContext.Response.StatusCode= 406;        } }
  • 52. Bibliography http://www.infoq.com/articles/webber-rest-workflow http://www.infoq.com/articles/mark-baker-hypermedia http://barelyenough.org/blog/2007/05/hypermedia-as-the-engine-of-application-state/ http://third-bit.com/blog/archives/1746.html http://www.learnxpress.com/create-restful-wcf-service-api-step-by-step-guide.html http://www.infoq.com/articles/rest-soap-when-to-use-each http://www.prescod.net/rest/ http://www.prescod.net/rest/rest_vs_soap_overview/ http://www.devx.com/DevX/Article/8155 http://tomayko.com/writings/rest-to-my-wife http://en.wikipedia.org/wiki/Representational_State_Transfer http://en.wikipedia.org/wiki/HATEOAS http://en.wikipedia.org/wiki/SOAP http://en.wikipedia.org/wiki/SOA http://en.wikipedia.org/wiki/Web_Application_Description_Language http://en.wikipedia.org/wiki/WSDL http://en.wikipedia.org/wiki/JSON-RPC http://en.wikipedia.org/wiki/XML-RPC http://www.sitepen.com/blog/2008/03/19/pluggable-web-services-with-smd/
  • 53. For further reading http://jcalcote.wordpress.com/2009/08/10/restful-authentication/ http://jcalcote.wordpress.com/2009/08/06/restful-transactions/ http://www.artima.com/lejava/articles/why_put_and_delete.html http://www.markbaker.ca/2002/08/HowContainersWork/ http://www.w3.org/Protocols/rfc2616/rfc2616.html http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-vs-put/ http://blog.whatfettle.com/2006/08/14/so-which-crud-operation-is-http-post/ http://cafe.elharo.com/web/why-rest-failed/ http://en.wikipedia.org/wiki/Windows_Communication_Foundation
  • 54. Thank you for listening!