WS serves as an interface to software developers.
Using WS as an API you can convert applications into web-applications.
WS is the vision of ‘Future Internet’
The basic Web services platform is XML + HTTP.
WS is future for Mobile application
2. Who am I
Have 9 + years of experience in open source specially
PHP, Drupal & Web Services.
Active crusader to improve effectiveness and reach of
Free & Open Source Software(FOSS).
Impart industrial consultancy for best use of software
application.
Frequently conduct training for students and
industrial experts.
3. What am I going to talk about ?
Use of Web Services ?
What is Web Services
Different Ways: SOAP & REST
SOAP Vs REST
How am I going to use REST
Example: Twitter, Paypal
4. Use of Web Services(WS)
Payment Gateway integration for E-commerce site.
Google Map for a Real Estate Site.
Product detail for a price comparison website
Weather forecast for a news or blog site
Mashup: Combine data from one or more source and
integrate application
6. Why WS for Payment getaway
Very Fast
Very Reliable
Secure
User don’t know what getway used by the site
User don’t need to register on payment site e.g. paypal
Website Administration is very easy e.g. IRCT with
netbanking ICICI
8. Top APIs for Mashups
http://programmableweb.com/apis
9. What is Web Services(WS)
WS serves as an interface to software
developers.
Using WS as an API you can convert
applications into web-applications.
WS is the vision of ‘Future Internet’
The basic Web services platform is XML +
HTTP.
WS is future for Mobile application
10.
11. What is SOAP
SOAP is a simple XML-based protocol to let
applications exchange information over HTTP
Businesses can register their WS on UDDI(Universal
Description, Discovery and Integration) and provide
documentation with WSDL (Web Services Description
Language).
SOAP is mostly used for Enterprise applications to
integrate wide types and another trend is to integrate
with legacy systems
19. PHP SOAP Server Example
$server = new SoapServer("Library.wsdl",array("classmap"=>$classmap));
$server->addFunction("searchAuthors");
$server->addFunction("searchBooks");
$server->handle();
21. RESTful Web services
Representational State Transfer (REST) has gained
widespread acceptance across the Web
REST permits many different data formats
HTTP consists in URIs, methods, status codes …
REST is great for clean, simple, robust services
REST is a software architecture style used in
developing stateless web services
REST is an acronym standing for Representational
State Transfer.
23. RESTful Web Service HTTP methods
HTTP CRUD SQL
POST Create INSERT
GET Read SELECT
PUT Update UPDATE
DELETE Delete DELETE
24. Data Format Supported By REST
xml – almost any programming language can read
XML
json – useful for JavaScript and increasingly PHP apps.
csv – open with spreadsheet programs
html – a simple HTML table
php – Representation of PHP code that can be
eval()’ed
serialize – Serialized data that can be unserialized in
PHP
25. Different Methods to Interact with REST
file_get_contents()
cURL
SimpleXml
26. 1) File_get_contents()
<?php
$result = file_get_contents('http:// twitter
.com/users/show/screenname');
var_dump($result);
HTTP Basic authentication you can use the following syntax to get data
from your password protected RESTful AP
$user = json_decode(
file_get_contents('http://admin:1234@example.com/index.php/api/use
r/id/1/format/json')
);
echo $user->name;
27. REST from PHP: GET(CURL)
<?php
$ch = curl_init('http://twitter.com/users');
curl_exec($ch);
30. Why REST /1
Creating clients, developing APIs, and understanding
documentation is much easier in REST than SOAP
REST permits many different data formats where as
SOAP only permits XML
JSON is a better fit for data and parses very faster
REST allows better support for browser clients due to
it’s support for JSON
REST reads can be cached, SOAP based reads cannot
be cached.
REST has better performance and scalability.
31. Why SOAP /2
WS-Security: SOAP supports SSL (just like REST) it also
supports WS-Security which adds some enterprise security
features.
WS-AtomicTransaction: Need ACID Transactions over a service
then you need SOAP. While REST supports transactions, it isn’t
as comprehensive and isn’t ACID compliant
WS-ReliableMessaging: Rest doesn’t have a standard
messaging system and expects clients to deal with
communication failures by retrying. SOAP has successful/retry
logic built in and provides end-to-end reliability even through
SOAP intermediaries.
32. SOAP Vs REST /3
In Summary, SOAP is clearly useful, and important.
For instance, if I was writing an iPhone application to
interface with my bank I would definitely need to use
SOAP. All three features above are required for
banking transactions. For example, if I was
transferring money from one account to the other, I
would need to be certain that it completed. Retrying it
could be catastrophic if it succeed the first time, but
the response failed.