Top Banner
Working with Web Services SOAP & Rest Mandakini Kumari June 15 th 2012
34

Web services soap and rest by mandakini for TechGig

Jan 15, 2015

Download

Technology

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
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 1. Mandakini KumariJune 15th 2012

2. Who am I Have 9 + years of experience in open source speciallyPHP, Drupal & Web Services. Active crusader to improve effectiveness and reach ofFree & Open Source Software(FOSS). Impart industrial consultancy for best use of softwareapplication. Frequently conduct training for students andindustrial 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 5. Payment Gateway integrationhttp://paypal.com 6. Why WS for Payment getaway Very Fast Very Reliable Secure User dont know what getway used by the site User dont need to register on payment site e.g. paypal Website Administration is very easy e.g. IRCT with netbanking ICICI 7. Google Map Web services for your website 8. Top APIs for Mashupshttp://programmableweb.com/apis 9. What is Web Services(WS) WS serves as an interface to softwaredevelopers. Using WS as an API you can convertapplications 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. What is SOAP SOAP is a simple XML-based protocol to letapplications exchange information over HTTP Businesses can register their WS on UDDI(UniversalDescription, Discovery and Integration) and providedocumentation with WSDL (Web Services DescriptionLanguage). SOAP is mostly used for Enterprise applications tointegrate wide types and another trend is to integratewith legacy systems 11. SOAP Architecture 12. SOAP Building Blocks 13. Paypal SOAP Building Blocks 14. A SOAP Envelope .... 15. SOAP Header Element api_usernameapi_passwordapi_signatureauthorizing_account_emailaddress 16. SOAP Body Request Element Laptop 17. A SOAP Response HTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn$900 18. PHP SOAP Server Example$server = new SoapServer("Library.wsdl",array("classmap"=>$classmap));$server->addFunction("searchAuthors");$server->addFunction("searchBooks");$server->handle(); 19. PHP SOAP Client Example$client=new SoapClient("http://localhost/Library.wsdl",array("trace" => 1));try{ //$response = $client->searchAuthors("Beh"); $response = $client->searchBooks("te");var_dump($response);echo htmlspecialchars($client->__getLastRequest())."";echo htmlspecialchars($client->__getLastResponse())."";}catch(Exception $e){ var_dump($e); echo $client->__getLastRequest();echo $client->__getLastResponse();} 20. RESTful Web services Representational State Transfer (REST) has gainedwidespread 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 indeveloping stateless web services REST is an acronym standing for RepresentationalState Transfer. 21. Architecture of REST 22. RESTful Web Service HTTP methodsHTTP CRUD SQLPOSTCreate INSERT GETRead SELECT PUTUpdate UPDATEDELETEDelete DELETE 23. Data Format Supported By REST xml almost any programming language can readXML 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 beeval()ed serialize Serialized data that can be unserialized inPHP 24. Different Methods to Interact with REST file_get_contents() cURL SimpleXml 25. 1) File_get_contents()