1 / 24

Web Services

Web Services. Aug’10 – Dec ’10 . Introduction . Web Services enable objects on one computer to call and make use of objects on other computers – distributed computing Chapter includes ❑ What a remote procedure call (RPC) is, and what RPC protocols exist currently

Télécharger la présentation

Web Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Services Aug’10 – Dec ’10

  2. Introduction Web Services enable objects on one computer to call and make use of objects on other computers – distributed computing Chapter includes ❑ What a remote procedure call (RPC) is, and what RPC protocols exist currently ❑ Why web services can provide more flexibility than previous RPC protocols ❑ How XML-RPC works ❑ Why most web services implementations should use HTTP as a transport protocol, and how HTTP works under the hood ❑ How the specifications that surround web services fit together Aug’10 – Dec ’10

  3. What Is RPC? When code on one computer calls code on another computer, this is called a remote procedure call (RPC) Aug’10 – Dec ’10

  4. What you should know: ❑ Where does the code you want to call reside? ❑ Does the code need any parameters? what type? ❑ Will the procedure return any data? in what format? Aug’10 – Dec ’10

  5. RPC protocols set of rules that enables different applications, or even different computers, to communicate. DCOM (Distributed Component Object Model) and IIOP (Internet Inter-ORB Protocol) – based on COM and CORBA respectively and JAVA RMI. Protocols specify how to provide an address for the remote computer, how to package data to be sent to the remote procedures, how to retrieve a response, how to initiate the call, how to deal with errors, etc Aug’10 – Dec ’10

  6. DCOM- Distributed Component Object Model Extenxtion of Microsoft’s Component Object Model component-based software can write a COM object in virtually any programming language ex: Microsoft Office major drawback: Microsoft specific! Aug’10 – Dec ’10

  7. IIOP :Internet Inter-ORB Protocol Common Object Request Broker Architecture, or CORBA any CORBA object can talk to any other enabling components to run on different platforms Neither COM nor CORBA are easy to work with! “DLL hell “ - (mismatched incompatible versions of libraries of a machine) Aug’10 – Dec ’10

  8. Java RMI Remote Method Invocation Java RMI can do one thing DCOM and IIOP can’t: It can transfer code with every call drawback to Java RMI: ties the programmer to one programming language Aug’10 – Dec ’10

  9. The New RPC Protocol: Web Services a web service is a service that accepts a request and returns data or carries out a processing task XML web services: atleast request or response consists of XML two main designs for XML Web services: XML-RPC a document approach Aug’10 – Dec ’10

  10. XML-RPC (Remote Procedure Call) calling a remote procedure by specifying the procedure to call and the parameters to pass Client sends command encoded in XML Server performs RPC, returns response in XML Internet Topic Exchange Aug’10 – Dec ’10

  11. The Target API three available methods: structtopicExchange.getChannels() structtopicExchange.ping(string topicName, struct details) structtopicExchange.getChannelInfo(string topicName) Aug’10 – Dec ’10

  12. A Simple Request <methodCall> <methodName> topicExchange.getChannels </methodName> </methodCall> Passing Parameter <methodCall> <methodName>topicExchange.ping</methodName> <params> <param> <value><string>books</string></value> </param> </params> </methodCall> Aug’10 – Dec ’10

  13. Using a struct : named values <methodCall> <methodName>topicExchange.ping</methodName> <params> <param> <value><string>books</string></value> </param> <param> <value> <struct> <member> <name>blog_name</name> <value><string>Wiley Today</string></value> </member> <member> <name>url</name> <value> <string>http://www.wiley.com/WileyCDA/Section/index.html </string> </value> </member> </struct> </value> </param> </params> </methodCall> Aug’10 – Dec ’10

  14. A struct can have a struct as one or more of its members <methodResponse> <params> <param> <value> <struct> <member> <name>channels</name> <value> <struct> <member> <name>books</name> <value> <struct> <member> <name>url</name> <value> <string>http://topicexchange.com/t/books/</string> </value> </member> </struct> </value> </member> Aug’10 – Dec ’10

  15. <member> <name>logic</name> <value> <struct> <member> <name>url</name> <value> <string>http://topicexchange.com/t/logic/</string> </value> </member> </struct> </value> </member> <!-- more member elements --> </struct> </value> </member> </struct> </value> </param> </params> </methodResponse> Aug’10 – Dec ’10

  16. The Network Transport to send and receive messages HTTP - Hypertext Transfer Protocol - a request/ response protocol HTTP request: 1. The client (in most cases, the browser) opens a connection to the HTTP server. 2. The client sends a request to the server. 3. The server performs some processing. 4. The server sends back a response. 5. The connection is closed Aug’10 – Dec ’10

  17. HTTP message- headers and optional body • each header (simple text) separated from the next by a new line character • body (text or binary) is separated from the headers by two newline characters • A browser request to the server Aug’10 – Dec ’10

  18. For a GET request, there is no body in the HTTP message A Server Response HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Date: Fri, 09 Mar 2007 15:30:52 GMT Content-Type: text/html Last-Modified: Thu, 06 Mar 2007 12:19:57 GMT Content-Length: 98 <html> <head><title>Hello world</title></head> <body> <p>Hello world</p> </body> </html> Aug’10 – Dec ’10

  19. An HTML page with form <html> <head> <title>Test form</title> </head> <body> <form action=”acceptform.asp” method=”POST”> Enter your first name: <input name=”txtFirstName” /><br /> Enter your last name: <input name=”txtLastName” /><br /> <input type=”submit” /> </form> </body> </html> Aug’10 – Dec ’10

  20. POST to acceptform.asp POST /acceptform.asp HTTP/1.1 Accept: */* Referer: http://www.wiley.com/myform.htm Accept-Language: en-us Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Win32) Host: www.wiley.com Content-Length: 36 txtFirstName=Joe&txtLastName=Fawcett Aug’10 – Dec ’10

  21. Why HTTP for Web Services? ❑ HTTP is already a widely implemented, and well understood, protocol. ❑ The request/response paradigm lends itself to RPC well. ❑ Most firewalls are already configured to work with HTTP. ❑ HTTP makes it easy to build in security by using Secure Sockets Layer (SSL). Aug’10 – Dec ’10

  22. Request/Response 1. Open a connection to the server providing the XML-RPC service. 2. Send the information on the entry to be added. 3. Process the addition. 4. Get back the result, including an error code if it didn’t work, or a ping identifier if it did. 5. Close the connection. Aug’10 – Dec ’10

  23. Using HTTP for XML-RPC Need to do two things with the client For the HTTP method, use POST. For the body of the message, include an XML document comprising the XML-RPC request POST /RPC2 HTTP/1.1 Accept: */* Accept-Language: en-us Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0) Host: www.wiley.com Content-Length: 79 <methodCall> <methodName>topicExchange.getChannels</methodName> </methodCall> Aug’10 – Dec ’10

  24. Aug’10 – Dec ’10

More Related