1 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC.

Slides:



Advertisements
Similar presentations
XML in the real world (2) SOAP. What is SOAP? ► SOAP stands for Simple Object Access Protocol ► SOAP is a communication protocol ► SOAP is for communication.
Advertisements

SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013.
XML-RPC Remote Procedure Call (RPC) is a model that specifies how cooperating processes on different nodes in a heterogeneous computing environment can.
GridRPC Sources / Credits: IRISA/IFSIC IRISA/INRIA Thierry Priol et. al papers.
HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
Middleware Fatemeh Hendijanifard 1 آزمايشگاه سيستم هاي هوشمند (
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
16-Jun-15 HTTP Hypertext Transfer Protocol. 2 HTTP messages HTTP is the language that web clients and web servers use to talk to each other HTTP is largely.
HTTP Hypertext Transfer Protocol. HTTP messages HTTP is the language that web clients and web servers use to talk to each other –HTTP is largely “under.
The World Wide Web and the Internet Dr Jim Briggs 1WUCM1.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
XML-RPC The Quickest Way to Web Services. THE MOVES INSTITUTE XML-RPC XML-RPC is an attempt to implement conventional Remote Procedure Call (RPC) concepts.
Web programming for project students Dr Jim Briggs.
JSP Architecture  JSP is a simple text file consisting of HTML or XML content along with JSP elements  JSP packages define the interface for the compiled.
Client, Server, HTTP, IP Address, Domain Name. Client-Server Model Client Bob Yahoo Server yahoo.com/finance.html A text file named finance.html.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
ODBC and JDBC What are they – libraries of function calls that support SQL statements Why do we need them –Provide a way for an application to communicate.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Web Servers Web server software is a product that works with the operating system The server computer can run more than one software product such as .
Web technologies and programming cse hypermedia and multimedia technology Fanis Tsandilas April 3, 2007.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
What are Web Services? Definition of web service A web service is a distributed unit of business logic that can be accessed over Internet standard web.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
SSC2: Web Services. Web Services Web Services offer interoperability using the web Web Services provide information on the operations they can perform.
HyperText Transfer Protocol (HTTP).  HTTP is the protocol that supports communication between web browsers and web servers.  A “Web Server” is a HTTP.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
Remote Procedure Calls Babak Esfandiari. RPC Introduced by Birrell & Nelson (1984) Remote Procedure Calls allow a program to make use of procedures executing.
XML-RPC Cvičení 8 - DS Úvod XML RPC Volání vzdálených podprogramů.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Current Trends in Network- Based Application Developments Bill Chu Department of Software and Information Systems UNC Charlotte.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
CSE 131 Computer Science 1 Module 1: (basics of Java)
1 EIE424 Distributed Systems and Networking Programming –Part II 3.1 SOAP – Introduction.
Web Server Design Assignment #1: Basic Operations Due: 02/03/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin.
1-1 HTTP request message GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr request.
Simple Object Access Protocol. Web Services: SOAP2 Why Simple Object Access Protocol Light weight replacement for complicated distributed object technology.
CliServ. J2EE/141 Client/Server Distributed Systems v Objectives –introduce the J2EE specification, and the J2EE SDK –other approaches: Struts,
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
WEB SERVER Mark Kimmet Shana Blair. The Project Web Server Application  Receives request for web pages or images from a client browser via the internet.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
Using the while-statement to process data files. General procedure to access a data file General procedure in computer programming to read data from a.
Basic JSP Celsina Bignoli Problems with Servlets Servlets contain –request processing, –business logic –response generation all lumped.
RESTful Web Services What is RESTful?
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
EGEE is a project funded by the European Union under contract IST SOAP Simple Object Access Protocol 3 – 4 June
Overview of Servlets and JSP
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Netprog: Soap & XML-RPC1 XML-RPC and SOAP. Netprog: Soap & XML-RPC2 XML Extensible Markup Language Markup Language. –HTML is also a markup language (but.
Network Programming: Servers. Agenda l Steps for creating a server Create a ServerSocket object Create a Socket object from ServerSocket Create an input.
Data Communication EDA344, DIT420 Description of Lab 1 and Optional Programming HTTP Assignment Bapi Chatterjee Prajith R G.
CSE 4939 Alex Riordan Brian Pruitt-Goddard. Design an interactive source control application that works between an android phone and a project located.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
Net-centric Computing Web Services. Lecture Outline  What is Web Service  Web Service Architecture  Creating and using Java Web Services  Apache Axis.
SOAP, Web Service, WSDL Week 14 Web site:
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Web Programming Week 1 Old Dominion University Department of Computer Science CS 418/518 Fall 2007 Michael L. Nelson 8/27/07.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 9 Web Services: JAX-RPC,
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
XML-RPC a lightweight data communication protocol
XML-RPC.
CIS Distributed and Parallel Architectures
Presentation transcript:

1 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

2 What is XML-RPC? XML-RPC provides an XML- and HTTP-based mechanism for making method or function calls across a network – Use XML for messaging (use only a small XML vocabulary set) – Use HTTP to pass information from a client computer to a server computer No notion of objects No mechanism for including information that uses other XML vocabularies Emerged in early 1998 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

3 Why XML-RPC? As distributed systems become more common, there is a need to integrate the applications in different computers, even within a company XML-RPC provides a simple tool to connect disparate parts inside a private network Linux Windows Private Network App A App B App A App B Client Server Client XML-RPC EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

4 XML-RPC can also provide a simple interface to a computer for other computers in the world to access Similar to the case that a Web page is a human readable interface of a computer Web Server HTTP GET HTTP response with HTML page XML-RPC Server XML-RPC Client oreillynet.com XML-RPC Request XML-RPC Response Headline information Other App Headline EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

5 Data Model – A set of type for passing parameters, return values and faults (error messages) – Use by both request and response Request Structure – An HTTP post request containing method name and parameter information Response Structure – An HTTP response containing return values or fault information EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC Three Main Parts of XML-RPC

6 XML-RPC Data Model Define only 6 basic data types and 2 compound data types Seems to be enough for most practical applications EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC Basic Type namesDescription int or i432-bit integers double64-bit floating pt booleantrue(1) or false(0) stringASCII text, usually support Unicode dateTime.iso8601Dates in ISO8601 format: CCYYMMDDTHH:MM:SS base64Binary defined as in RFC2045

7 Some examples: – 27 – – 1 – Hello – T02:20:04 – SGVsbG8sIFdvcmxkIQ== These basic types are always enclosed in value elements EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

8 These basic types can be combined into two more complex types: Array and Struct EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC This is an array. This is an array.

9 Arrays can contain mixtures of different types 1 Chan Tai-Man Chan Tai-Man EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

10 Arrays can be multi- dimensional E.g First Row Second Row EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

11 Struct contains unordered content, identified by name Names are string, although it is not necessary to enclose them by string elements Each struct element contains a list of member elements Member elements each contain one name element and one value element The order of members is not important EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

12 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC givenName Tai-Man familyName Chan age 27 givenName Tai-Man familyName Chan age 27 First member of the struct Second member of the struct Third member of the struct

13 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC Name a attributes href target _top Name a attributes href target _top Nest a struct inside a struct We can also nest an array inside a struct

14 XML-RPC Request Structure EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC XML-RPC requests are a combination of XML content and HTTP headers – HTTP header: a wrapper for passing the request over the Web POST /xmlrpc HTTP 1.0 User-Agent: myXMLRPCClient/1.0 Host: Content-Type: text/html Content-Length: 169 : XML statements : POST /xmlrpc HTTP 1.0 User-Agent: myXMLRPCClient/1.0 Host: Content-Type: text/html Content-Length: 169 : XML statements : – XML content: pass parameters and identify the procedure to be called For example

15 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC circleArea circleArea The XML statements contain the method name and passed parameters Input parameters: a double and an array Method to be called

16 XML-RPC Response Structure EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC If a request is successful – the procedure was found, executed correctly, the result will be returned thru the response to the client Similar to request, a response needs to be attached to a HTTP header for surfing on the Web HTTP/ OK Date: Sat, 06 Oct :20:04 GMT Server: Apache (Unix) Connection: close Content-Type: text/html Content-Length: 124 : XML statements : HTTP/ OK Date: Sat, 06 Oct :20:04 GMT Server: Apache (Unix) Connection: close Content-Type: text/html Content-Length: 124 : XML statements : For example

17 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC No such method! No such method! Return a double number Return a fault, no standardized error code

18 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC code 26 message No such method! code 26 message No such method! Return a struct The error code is created by the app. Can only be understood in this app. Return a struct The error code is created by the app. Can only be understood in this app.

19 Developing With XML-RPC In real applications, we do not need to directly program the XML statements Only need to add an XML-RPC library and making some function calls thru this library Hence can be done by using any programming languages, such as Java For example, the Apache XML Project’s Apache XML-RPC has provided packages that make integrating XML-RPC with Java easier EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

20 Apache XML-RPC Provide an automated registration process for adding methods to the XML-RPC server Provide a built-in server that only speaks XML- RPC, reducing the need to create full-blown servlets A client package that makes calling remote methods fairly simple EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC

21 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC Prepare for XML-RPC Services Develop the function to be called by the client Develop the function to be called by the client Create the server Create the server Register the function to the server Register the function to the server Start the server Start the server

22 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC Develop The Function public class AreaHandler { public double circleArea(double radius) { double value = (radius*radius*Math.PI); return value; } public class AreaHandler { public double circleArea(double radius) { double value = (radius*radius*Math.PI); return value; } Just a normal function that returns the area (double) of a circle based on the input radius Function name: circleArea Input parameter: the radius (double)

23 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC Create Server and Register Function import java.io.IOException; import org.apache.xmlrpc.WebServer; import org.apache.xmlrpc.XmlRpc; import java.io.IOException; import org.apache.xmlrpc.WebServer; import org.apache.xmlrpc.XmlRpc; First, import the libraries

24 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC public class AreaServer { public static void main(String[] args) { try { startServer(args); } catch (IOException e) {;} } public static void startServer(String[] args) throws IOException { WebServer server = new WebServer( Integer.parseInt(args[0])); server.addHandler(“area”,new AreaHandler()); server.start(); } public class AreaServer { public static void main(String[] args) { try { startServer(args); } catch (IOException e) {;} } public static void startServer(String[] args) throws IOException { WebServer server = new WebServer( Integer.parseInt(args[0])); server.addHandler(“area”,new AreaHandler()); server.start(); } Should input a port number Convert to an integer Register the class under the name “area” Start server

25 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC To fire up the server, just execute the class from the command line – need specifying a port no. Assume the class has been compiled and the file AreaServer.class has been generated >java AreaServer 8899 port number for the server

26 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC Developing the Client Program To call the function registered in the server, a tailor- made client program is required Also need to use the XML-RPC libraries import java.io.IOException; import java.util.Vector; import org.apache.xmlrpc.XmlRpc; import org.apache.xmlrpc.XmlRpcClient; import org.apache.xmlrpc.XmlRpcException; import java.io.IOException; import java.util.Vector; import org.apache.xmlrpc.XmlRpc; import org.apache.xmlrpc.XmlRpcClient; import org.apache.xmlrpc.XmlRpcException;

27 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC public class AreaClient { public static void main(String[] args) { AreaClient client = new AreaClient(); double radius = Double.parseDouble(args[0]); try { double area = client.areaCircle(radius); System.out.println(“The area of the circle would be: “ + area); } catch (IOException e) {;} catch (XmlRpcException e) {;} } public double areaCircle (double radius) throws IOException, XmlRpcException { : } public class AreaClient { public static void main(String[] args) { AreaClient client = new AreaClient(); double radius = Double.parseDouble(args[0]); try { double area = client.areaCircle(radius); System.out.println(“The area of the circle would be: “ + area); } catch (IOException e) {;} catch (XmlRpcException e) {;} } public double areaCircle (double radius) throws IOException, XmlRpcException { : } Call areaCircle(), if OK, report the result Cast to double

28 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC public double areaCircle (double radius) throws IOException, XmlRpcException { XmlRpcClient client = new XmlRpcClient( Vector params = new Vector(); params.addElement(new Double (radius)); Object result = client.execute(“area.circleArea”, params); String resultStr = result.toString(); double area = Double.parseDouble(resultStr); return area; } public double areaCircle (double radius) throws IOException, XmlRpcException { XmlRpcClient client = new XmlRpcClient( Vector params = new Vector(); params.addElement(new Double (radius)); Object result = client.execute(“area.circleArea”, params); String resultStr = result.toString(); double area = Double.parseDouble(resultStr); return area; } Create a client and connect to the server at port 8899 Add a Double object to the Vector object Call the server function. The registered name “area” and function name need to be known Just to play safe

29 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC By executing this program, a HTTP request will be generated. An example is shown as follows: POST / HTTP/1.1 Content-Length: 175 Content-Type: text/xml User-Agent: Java1.3.0 Host: localhost:8899 Accept: text/html, image/gif, image/jpeg Connection: keep-alive area.circleArea 3.0 POST / HTTP/1.1 Content-Length: 175 Content-Type: text/xml User-Agent: Java1.3.0 Host: localhost:8899 Accept: text/html, image/gif, image/jpeg Connection: keep-alive area.circleArea 3.0 HTTP header XML messages

30 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC If everything is fine, the server will send back the methodResponse and embedded inside the HTTP response Assume the client program is compiled and the AreaClient.class is generated The result looks pretty simple >java AreaClient 3 The area of the circle would be: … >java AreaClient 4 The area of the circle would be: … >java AreaClient 3 The area of the circle would be: … >java AreaClient 4 The area of the circle would be: …

31 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC Concluding Remarks Java is only a tool for us to generate the XML messages Other programming languages can be used to do the same. For example, Perl For XML-RPC, client needs to have some knowledge of server’s registered functions No way for the server to publicize its functions or to allow the client to automatically obtain such info Hence does not perfectly fit the requirements of Web Services