Más contenido relacionado

Último(20)

Web Service

  1. WEB SERVICES (REST / SOAP) Presented By: Ashwani (Sr. Software Engineer)
  2. What is Web Service lA software system designed to support communication between machine-to-machine over a network lprovide standared format of communication lPlatform independent communication Built on PHP OS: Apache Built on .NET OS: Windows
  3. Where we use Web Service lWeb services allows you to expose the functionality of your existing code over the network. lOnce it is exposed on the network, other application can use the functionality of your program without passing actual logic or code lCan be consider as a class and object in refrence of OOPS lLike Payment Gatway, google API, etc
  4. Where we can use Web Service API
  5. Where we can use Web Service SMS Service Organization Other Bussiness organization API Request API Response
  6. SOAP (Simple Object Access Protocol) REST (Representational state transfer) Type Of Web Service Web Services
  7. How Web Services Work lLet assume two different platform is present lOne built on PHP( app1) and other on .NET(app2) and is on diffrent server lHere we need lmedium 'HTTP' / 'Internet' protocal lFormat XML / JSON (comman format that both will understand)
  8. SOAP lUse Meduim 'HTTP POST' Method lFormat is always XML
  9. REST lUse Medium “ HTTP POST PUT GET DELETE PATCH what ever format HTTP support” lUSE FORMAT XML, JSON, Text what ever format HTTP support
  10. What is Restful web service lA web service which is used to communicate between clinet- server using REST Arch. / principle. lREST is an architectural style, while SOAP is a protocol. REST is not a standard in itself, but RESTful implementations make use of standards, such as HTTP, URI, JSON, and XML.
  11. Principle of REST Architecture lUser interface lStateless lCacheable lLayered System lCode on Demand (optional)
  12. User Interface 1) Resource:- Every thing is resource 2) URI:- Any resource data can accessed by URI 3) HTTP:- make use of HTTP method
  13. Employee - id - name Designation - id - name And many more... 1. Resource: Every thing is resource Emplyee managment system
  14. Employee - id - name Designation - id - name And many more....... Emplyee managment system Employe e Designatio n 1. Resource: Every thing is resource
  15. Employee - id - name Designation - id - name And many more....... Emplyee managment system Employee Designatio n 1. Resource: Every thing is resource Every module of project we can define As Resource
  16. Employee - id - name Designation - id - name And many more....... Emplyee managment system Employe e Designatio n 1. Resource: Every thing is resource 2. URI: Any Resource can be accessed by URI (Uniform Resource Identifier) For Example: www.myrest.com/designation www.myrest.com/designation/1 0 Resource URI What will be url if i want all employee having given Designation?
  17. Employee - id - name Designation - id - name And many more....... Emplyee managment system Employe e Designatio n 1. Resource: Every thing is resource 2. URI: Any Resource can be accessed by URI (Uniform Resource Identifier) For Example: www.myrest.com/designation www.myrest.com/designation/1 0 Resource URI www.myrest.com/designation/10/employe e
  18. Employee - id - name Designation - id - name And many more....... Emplyee managment system Employe e Designatio n 1. Resource: Every thing is resource 2. URI: Any Resource can be accessed by URI (Uniform Resource Identifier) For Example: www.myrest.com/designation www.myrest.com/designation/1 0 Resource URI 3. HTTP Verb VERB lGET lPOST lPUT lDELETE
  19. Employee - id - name Designation - id - name And many more....... Emplyee managment system Employe e Designatio n 1. Resource: Every thing is resource 2. URI: Any Resource can be accessed by URI (Uniform Resource Identifier) For Example: www.myrest.com/designation www.myrest.com/designation/1 0 Resource URI 3. HTTP Verb VERB lGET lPOST lPUT lDELETE Nam e
  20. Stateless : lServer does not maintatin any data of any previous request has been made lNo Session lEvery request will be independent and its client responsiblity to send all details whatever needed fro that request lFor example: Client Serve r www.apicall.com/login + POST data (uname + pass) Response: { status: success, auth token: xyz } www.apicall.com/myPayslip + authtoken (in header)
  21. Cachin g lThis happen at client side. Responses must therefore, implicitly or explicitly, define themselves as cacheable or not to prevent clients from reusing lstale or inappropriate data in response to further requests lWell-managed caching partially or completely eliminates some client–server interactions, further improving scalability and performance.
  22. Layering: A client cannot ordinarily tell whether it is connected directly to the end server, or to an intermediary along the way. Intermediary servers may improve system scalability by enabling load balancing and by providing shared caches. They may also enforce security policies. Clinet ServerProxy Cache
  23. REST Summary lREST is architectural Structure lWe must follow all principle of REST in order to improve performace, Portablity, Visibility, Simplicity
  24. Web Service Authentication lFor Authentication you can use any logic which ever seems to be secure can be used lBasic Authentication l- pass username and password in header
  25. Web Service Authentication(cont.) lCustom Authentation lWhen login generate token and send in response lThis will be saved in cookies and will be used to pass along with further transaction by setting this in header lCan use Oauth2 lYou can create your own authentication(can change header), it totaly depends on developer only security is concern.
  26. Web Service Authentication(cont.) lCustom Authentation lWhen login generate token and send in response lThis will be saved in cookies and will be used to pass along with further transaction by setting this in header lCan use Oauth2 lYou can create your own authentication(can change header), it totaly depends on developer only security is concern.
  27. What is SOAP lSOAP is also web service but use medium as a POST lSOAP is protocol used for exchanging data between client and server lIT uses XML technologies as a messaging. lXML -> eXtensible Markup Language. lHTML -> Hyper text Markup Language lSOAP can work on HTTP, SMTP, FTP lSOAP is platform- and language-independent lSOAP defines its own security known as WS Security.
  28. Request and Response
  29. The SOAP Structure lA SOAP message contains 3 parts: lEnvelope: defines the content of the message lHeader (optional): contains header information lBody: contains call and response information From the http://schemas.xmlsoap.org/soap/envelope/ namespace
  30. SAOP Envelope The SOAP envelope indicates the start and the end of the message so that the receiver knows when an entire message has been received The Envelope is the top element of the XML document representing the message. The Envelope element is always the root element of a SOAP message. The Envelope element contains an optional Header element followed by a mandatory Body element.
  31. SOAP Envlope Code <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <!-- optional --> <!-- header blocks go here... --> </soap:Header> <soap:Body> <!-- payload or Fault element goes here... → </soap:Body> </soap:Envelope>
  32. SOAP Sample
  33. SOAP Example (cont.)
  34. SOAP Vs REST SOAP REST SOAP is a protocol REST is an architectural style. Standards to be strictly followed. does not define too much standards like SOAP. SOAP requires more bandwidth and resource than REST. REST requires less bandwidth and resource than SOAP. SOAP permits XML data format only. REST permits different data format such as Plain text, HTML, XML, JSON etc.