Before inventing web services, whenever we need to get data from a particular website, first we visit a website and with help of an HTTP request is sent to the server from web browsers and server responses display to the visitor.
We’ll comparison here between SOAP, XML-RPC and Restful types of web services.
Nowadays this scenario has been changed. You don’t need to visit the particular website to use their service and functionality if they are providing web services.
Web services are a set of platform-independent functions/APIs which can be used from a remote server over the Internet. In web services there are two parties involved one is a provider (Server) and the other is consumer(Client).
There are three types of web services available.
Types of Web Services
1- SOAP
2- XML-RPC
3- REST
Checkout other Web service Tutorials,
SOAP
Soap is a wonderful technology that can help you in developing great applications, It is formerly known as Simple Object Access Protocol (until the acronym was dropped in version 1.2). SOAP is an XML-based web service protocol.
In other words, SOAP is a simple XML-based protocol to provide the functionality to applications to exchange information over HTTP.SOAP is using SOAP-Envelope to transfer information. It has the typical architecture to create web services.
In PHP 7, there is a built-in extension for providing and consuming web services. But there are many library also available to create soap-based web services in PHP.
The SOAP extension implements a large subset of SOAP 1.1, SOAP 1.2 and WSDL 1.1 specifications.
Manual:
http://php.net/manual/en/book.soap.php
Pear packages:
http://pear.php.net/package/SOAP/redirected
XML-RPC
XML RPC is another useful technique for providing and consuming web services. It is using HTTP for transport and XML for encoding and decoding the remote procedure call along with its parameter.
You can visit the official website www.xmlrpc.com to know more about XML-RPC.XML-RPC has simple designed architecture and allows complex data structures to be transmitted, processed and returned.
There are many functions which is responsible to set request and get a response but mainly there are two functions xmlrpc_encode_request()
and xmlrpc_decode_request()
used to encode and decode XML-RPC request and response.
Features
- Support for creating both xmlrpc clients and servers.
- Fully automated or fully manual, fine-grained encoding and decoding from PHP values to xmlrpc.
- Support for
UTF8
,Latin-1
andASCII
character encodings. - Support for HTTP compression of both requests and responses, cookies, proxies, basic auth and HTTPS, NTLM auth and keepalives with the php cURL extension.
- Optional validation of parameter types of incoming xmlrpc request.
- Support for system.listMethods, system.methodHelp, system.multicall and system.getCapabilities methods.
- Support for the extensions to xmlrpc.
- Possibility to register PHP function or class methods as webservices, extracting value-added information from phpdoc comments.
- A web-based visual debugger is included with the library
Manual:
http://php.net/manual/en/book.xmlrpc.php
Pear packages:
http://pear.php.net/package/XML_RPC/redirected
REST
Its easiest technology to develop web services. Its stand for Representational State Transfer (REST). Nowadays, it’s very becoming popular in the arena of web services. There is no need to use XML data interchange format for request and response.
The REST web services can be return XML, JSON or even in HTML format response. PHP already has many functions to handle these type of response or requests like DOM functions, SimpleXML
functions and Json encode/decode functions.
REST architecture is basically focused on two things:
- Resources : Its application functionality which is represented by a unique URL.
- Interface : its HTTP methods works as an interface to access the resources.
If you have any questions or queries,Please comment here.