Web services for developer

956 views

Published on

Web services for developer

Published in: Technology
  • Be the first to comment

Web services for developer

  1. 1. Web Services For Developer -Rafiq Ahmed
  2. 2. Web Services <ul><li>Web Service is piece of business logic that </li></ul><ul><ul><li>Accessible through standard protocol , such as HTTP,SMTP. </li></ul></ul><ul><ul><li>Platform and language independent . </li></ul></ul>
  3. 3. Core technologies used for Web services <ul><li>XML (Extensible Markup Language) is the markup language that underlies most of the specifications used for Web services. It's a generic language that can be used to describe any kind of content in a structured way, separated from its presentation to a specific device. </li></ul><ul><li>SOAP (Simple Object Access Protocol) is a network, transport, and programming language and platform-neutral protocol that allows a client to call a remote service. The message format is XML. </li></ul>
  4. 4. Core technologies used for Web services <ul><li>WSDL (Web Services Description Language) is an XML-based interface and implementation description language. It is in order to specify the operations a Web service provides and the parameters and data types of these operations </li></ul><ul><li>WSIL (Web Services Inspection Language) is an XML-based specification about how to locate Web services without the necessity of using UDDI. However, WSIL can be also used together with UDDI, that is, it is orthogonal to UDDI and does not replace it. </li></ul><ul><li>UDDI (Universal Description, Discovery, and Integration) is both a client-side API and a SOAP-based server implementation that can be used to store and retrieve information on service providers and Web services. </li></ul>
  5. 5. WSDL <ul><li>The WSDL document contains the following main elements </li></ul><ul><ul><li>Types </li></ul></ul><ul><ul><li>Message </li></ul></ul><ul><ul><li>Port type </li></ul></ul><ul><ul><li>Operation </li></ul></ul><ul><ul><li>Binding </li></ul></ul><ul><ul><li>Service </li></ul></ul><ul><ul><li>Port </li></ul></ul>
  6. 6. WSDL Structure
  7. 7. WSDL <ul><li>The WSDL document contains the following main elements: </li></ul><ul><li>Types </li></ul><ul><ul><li>The types element describes all the data types used between the client and server </li></ul></ul><ul><ul><li><definitions .... > </li></ul></ul><ul><ul><li><types> </li></ul></ul><ul><ul><li><xsd:schema .... />(0 or more) </li></ul></ul><ul><ul><li></types> </li></ul></ul><ul><ul><li></definitions> </li></ul></ul><ul><ul><li>It’s provide an XML container element to define additional type information in case the XSD type system does not provide sufficient modeling capabilities. </li></ul></ul>
  8. 8. <ul><li>Messages </li></ul><ul><ul><li>A message represents one interaction between a service </li></ul></ul><ul><ul><li>requestor and service provider. </li></ul></ul><ul><ul><li><definitions .... > </li></ul></ul><ul><ul><li><message name=&quot;nmtoken&quot;> (0 or more) </li></ul></ul><ul><ul><li><part name=&quot;nmtoken&quot; element=&quot;qname&quot; (0 or 1) type=&quot;qname&quot; (0 or 1) /> </li></ul></ul><ul><ul><li>(0 or more) </li></ul></ul><ul><ul><li></message> </li></ul></ul><ul><ul><li></definitions> </li></ul></ul><ul><ul><li>The message element describes a one-way message, </li></ul></ul><ul><ul><li>whether it is a single message request or a single </li></ul></ul><ul><ul><li>message response. </li></ul></ul>
  9. 9. <ul><li>Port types </li></ul><ul><li>The portType element combines multiple message elements to form a complete </li></ul><ul><li>one-way or round-trip operation. </li></ul><ul><ul><li>WSDL supports four basic patterns of operation: </li></ul></ul><ul><ul><ul><li>One-Way </li></ul></ul></ul><ul><ul><ul><li>Request-Response </li></ul></ul></ul><ul><ul><ul><li>Solicit-Response </li></ul></ul></ul><ul><ul><ul><li>Notification </li></ul></ul></ul>
  10. 10. <ul><li>Bindings </li></ul><ul><ul><li>The binding element describes the concrete specifics of how the service will be implemented on the wire . WSDL includes built-in extensions for defining SOAP services, and SOAP-specific information therefore goes here. </li></ul></ul><ul><ul><li>SOAP-specific details: </li></ul></ul><ul><ul><ul><li>soap:binding </li></ul></ul></ul><ul><ul><ul><ul><li>Transport- Which Protocol to be use? </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Style – Data representation style ? </li></ul></ul></ul></ul><ul><ul><ul><li>soap:operation </li></ul></ul></ul><ul><ul><ul><li>soap:body </li></ul></ul></ul><ul><ul><ul><ul><li>Use – How to do interpretation of data? </li></ul></ul></ul></ul>
  11. 11. <ul><li>Service definition </li></ul><ul><li>The service element specifies the location of the services via port. </li></ul><ul><li>Port </li></ul><ul><li>A port definition describes an individual endpoint by specifying a single address for a binding </li></ul>
  12. 12. WSDL 1.1 and WSDL 2.2
  13. 13. SOAP <ul><li>SOAP is a protocol specification for exchanging structured </li></ul><ul><li>information in the implementation of Web Services in </li></ul><ul><li>computer networks </li></ul><ul><li>Three pillars of SOAP </li></ul><ul><li>SOAP is an XML-based protocol that consists of three parts </li></ul><ul><li>Envelope with header and body </li></ul><ul><li>Encoding rules </li></ul><ul><li>Communication styles </li></ul>
  14. 14. SOAP Envelope <ul><li>An envelope containing zero or more headers and exactly one body </li></ul><ul><li>It might contain exceptions to report failures or unexpected conditions </li></ul><ul><li>Header tells who and how to deal with the message. </li></ul><ul><li>Body tells what has do be done. </li></ul>
  15. 15. SOAP: Encoding rules <ul><li>Encodings rules define how data values defined in the application can be translated to and from a protocol format. </li></ul><ul><ul><ul><li>The literal encoding is a simple XML message that does not carry encoding information. Usually, an XML Schema describes the format and data types of the XML message </li></ul></ul></ul><ul><ul><ul><li>The SOAP encoding enables marshalling/unmarshalling of values of data types from the SOAP data model. It contain information in EncodingStyle attribute of SOAP. </li></ul></ul></ul><ul><ul><li>Encoding to be used by the SOAP can be specified at deploy time or at runtime. </li></ul></ul>
  16. 16. SOAP: Communication styles <ul><li>RPC (remote procedure call) messaging is a synchronous invocation of operation returning a result, conceptually similar to other RPCs. </li></ul><ul><li>Document messaging Also known as message-oriented style: is a asynchronous invocation of operation returning a result, . The input parameter is any XML document; the response can be anything (or nothing). </li></ul>
  17. 17. RESTful Web Service
  18. 18. A Brief Introduction to RESTful WS <ul><li>Representational State Transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. </li></ul><ul><li>Also called as “RESTful HTTP” </li></ul><ul><li>Five key principles are: </li></ul><ul><ul><li>Give every “resource” an ID </li></ul></ul><ul><ul><li>Link things together </li></ul></ul><ul><ul><li>Use standard methods </li></ul></ul><ul><ul><li>Resources with multiple representations </li></ul></ul><ul><ul><li>Communicate statelessly </li></ul></ul>
  19. 19. <ul><li>Give every “resource” an ID </li></ul><ul><ul><li>ID here is URI - unique global ID. </li></ul></ul><ul><ul><li>Make URI - Resource-Oriented. </li></ul></ul><ul><ul><li>Do proper URI design around resource. </li></ul></ul><ul><ul><li>Bad:http://company1.com/jsp/foo/report.htm?type=sales&date=2009-3 </li></ul></ul><ul><ul><li>Good:http://company1.com/report/sales/2009/month/3 </li></ul></ul><ul><li>Link things together </li></ul><ul><ul><li>“ Hypermedia as the engine of application state” -HATEOAS. </li></ul></ul><ul><ul><li>Concept of hypermedia, or in other words: links . </li></ul></ul><ul><ul><li>URIs in sufficient context and info. </li></ul></ul>
  20. 20. <ul><li>Use standard methods </li></ul><ul><ul><li>set of operations supported by the web service using  HTTP methods  (e.g., POST, GET, PUT or DELETE). </li></ul></ul><ul><ul><li>RESTful HTTP approach - HTTP application protocol </li></ul></ul>Action Verb Create POST Retrieve GET Update PUT Delete DELETE
  21. 21. For clients to be able to interact with your resources, they should implement the default application protocol (HTTP) correctly, i.e. make use of the standard methods GET, PUT, POST, DELETE. And should return HTTP status code like 200, 404, 500 etc.
  22. 22. <ul><li>Resources with multiple representations. </li></ul><ul><ul><li>How does a server and client know that , how to deal with the data it retrieves? </li></ul></ul><ul><ul><li>Http header : Content-Type and Accept </li></ul></ul><ul><li>Communicate statelessly. </li></ul>
  23. 23. <ul><li>Summary ( What I can recall??) </li></ul>WS-* WSDL < - -> Interface SOAP < -- > Object RESTFul WS Resource < -- > URI Use Me :: GET – PUT – POST - DELETE Binding ; Litrel/Encoding HTTP ;SMTP
  24. 24. <ul><li>THE END </li></ul>

×