Saturday, May 5, 2012

XML-RPC Vs SOAP Vs REST

SOAP
SOAP was the acronym ofSimple Object Access Protocal but this acronym was dropped in the version of 1.2 of SOAP. It is method for exchanging XML based message over the Internet for providing and consuming web services. SOAP message are transferred forming the SOAP-Envelope.You can view the typicalSOAP Message articture from here. SOAP is widely criticized for it’s design complexity.
In PHP 5, there is built-in extension for the providing and consuming web services. But, I personally preferNusoap toolkit of PHP for providing and consuming web services using SOAP in PHP.
XML-RPC
XML-RPC (remote procedure call) another way of providing and consuming web services. It uses XML to encode and decode the remote procedure call along with it’s parameter. Compared to the articture of SOAP, it has simpler architecture. You can even define data type of parameters of procedure in XML-RPC. You can visit the official websitewww.xmlrpc.com to know more about XML-RPC.
In PHP, there is extension which contain various functions for facilating XML-RPC request and response. But the functionsxmlrpc_encode_request() andxmlrpc_decode_request() available in PHP is very useful for when it comes to encode and decode XML-RPC request and response.
REST
Representational State Trasfer(REST) is comparatively simpler method for providing and consuming web services. Nowadays, this method is becoming popular in the arena of web services. Unlike above two method, it is not necessary to use XML as a data interchange format in REST. REST architecture is basically focused on two things :Resources andInterface.RESTful is another term to define REST web services .
Resources are application’s state and functionality which is represented by a unique URL. The resources share a uniform interface to transfer the state between the client and server.
For example the URL, http://example.com/product/11 can be aresource.Suppose, GET method is used to retrieve product detail from that URL, POST method is used to modify the production information and DELETE method can be used to delete the product from the same URL. Here, the HTTP methods works as a interface to access the resources.
Talking about PHP, the format of information(representation) returned can be in XML, JSON or even in HTML format.DOM functions, SimpleXML functions and JSON functions comes handy when you are handling RESTful interfaces in PHP.
Ref:
http://en.wikipedia.org/wiki/REST

No comments: