XML-RPC. XML-RPC Architecture Client-server architecture Client executes RPCs on the server Server has 3 components: –The main thread –The XML-RPC server.

Slides:



Advertisements
Similar presentations
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Advertisements

Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
SE-1020 Dr. Mark L. Hornick 1 Exceptions and Exception Handling.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
9. Exceptions An exception occurs when our code asks the JVM to perform the technically impossible and unanticipated (by the compiler)! Under these circumstances,
J2ME RMI 1 Java 2 Platform, Micro Edition Implementation of J2ME RMI Application Farooq Sheikh.
CSE451 Section 6: Spring 2006 Web server & preemption.
XMLHttpRequest Object and XML What we should learn in this lesson –What is the XHR object? –How to create the XHR objects? –XHR object properties –XHR.
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 Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
Classes, Objects, Arrays, Collections and Autoboxing Dr. Andrew Wallace PhD BEng(hons) EurIng
CPSC 252 Exception Handling Page 1 Exceptions and exception handling Client programmers can make errors using a class attempting to dequeue an item from.
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
1 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
LOGO E-Radio code presentation Prepared By Abdullah Mustafa Abu Nada Hussian Abd-Jaleel Shaalan Nael Wael Skaik Software group.
Networking: Part 2 (Accessing the Internet). The UI Thread When an application is launched, the system creates a “main” UI thread responsible for handling.
Remote Procedure Calls Babak Esfandiari. RPC Introduced by Birrell & Nelson (1984) Remote Procedure Calls allow a program to make use of procedures executing.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Cli/Serv.: Chat/121 Client/Server Distributed Systems v Objectives –discuss a client/server based chat system –mention two other ways of chatting.
XML-RPC Cvičení 8 - DS Úvod XML RPC Volání vzdálených podprogramů.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Class 14: Object-Oriented Programming Fall 2010 University of Virginia David Evans cs2220: Engineering Software.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
C Derived Languages C is the base upon which many build C++ conventions also influence others *SmallTalk is where most OOP comes Java and Javascript have.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.
1 (Worker Queues) cs What is a Thread Pool? A collection of threads that are created once (e.g. when a server starts) That is, no need to create.
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 23 — Simple Object Access Protocol (SOAP) and Microsoft BizTalk™ Outline 23.1Introduction 23.2Simple.
Introduction to Socket Programming in Android Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
Dynamic Architectures (Component Reconfiguration) with Fractal.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
1 ObjectRiver Metadata Compilers Programmatic WebSockets JavaOne 2014 – Steven Lemmo.
CS603 Communication Mechanisms: SOAP 25 January 2002.
1 Developing Application in Distributed Computing Environment (DCE)
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Project Scenario for OpX. High-level Overview In the Test GUI Controller, opXController, for the opX command there is conceptually a call to an appropriate.
Remote Procedure Call and Serialization BY: AARON MCKAY.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Java Network Programming Network Programming Spring 2000 Jeffrey E. Care
Generics. Writing typed checked generic code There are many instances where the type of the object is irrelevant : –The construction of data structures.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Message Framework Topic subscribe for javascript/flex client.
CSE 4939 Alex Riordan Brian Pruitt-Goddard. Design an interactive source control application that works between an android phone and a project located.
Exception Handling How to handle the runtime errors.
Li Tak Sing COMPS311F. Case study: a multithreaded chat server The source contains 3 files: ChatServer //the chat server ChatThread //the thread on the.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Object Oriented Programming Lecture 2: BallWorld.
Lecture 5: RPC (exercises/questions). 26-Jun-16COMP28112 Lecture 52 First Six Steps of RPC TvS: Figure 4-7.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 9 Web Services: JAX-RPC,
C++ Lesson 1.
Why exception handling in C++?
XML-RPC a lightweight data communication protocol
null, true, and false are also reserved.
XML-RPC.
CIS Distributed and Parallel Architectures
Chapter 40 Remote Method Invocation
Exceptions 1 CMSC 202.
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
CMSC 202 Lesson 20 Exceptions 1.
Presentation transcript:

XML-RPC

XML-RPC Architecture Client-server architecture Client executes RPCs on the server Server has 3 components: –The main thread –The XML-RPC server (takes place of stubs) –One or more RPC handlers Server processes each RPC by calling the corresponding RPC handler

XML-RPC Architecture ClientServer XML-RPC Server RPC Handler HTTP

XML-RPC Types 4-byte signed integer Boolean String Double Date/Time (not fully ISO 8601 compatible!) –No time zone information Binary (base-64) Arrays of any of these types Structures containing these types –Map of element names to types/values

XML-RPC Libraries C++: xmlrpc-c – –Only installed on ccc1 right now Java: Apache XML-RPC – –Required: Apache commons-codec library –Use on any machine except ccc1 (no Java 1.5)

Client-Side XML-RPC 2 types of XML-RPCs –Synchronous –Asynchronous What is the difference? What are the advantages and disadvantages of each?

Synchronous XML-RPCs Client executes RPC on server –Client blocks until the RPC returns Server returns a generic object/type –C++ (xmlrpc-c) Library xmlrpc_c::value –Java (Apache) Library Object Client must know what type to expect –Cast generic type to expected type

Asynchronous XML-RPCs Client must define a call-back object –Method to handle RPC success –Method to handle RPC failure/error Client makes asynchronous RPC –Simply spawns a new thread for the RPC –Returns immediately When the RPC has finished, one of the call-back methods will be executed –Cast return value to expected type

Executing an XML-RPC 1. Build a list of RPC parameters –Analogous to function/method parameters 2. Initialize the RPC –Name of the RPC –URL (it’s HTTP) of the XML-RPC server 3. Execute the RPC 4. Handle errors 5. Interpret return value

Build a List of RPC Parameters C++ xmlrpc_c::paramList params; params.add( xmlrpc_c::value_string(“Hello server.”)); Java java.util.Vector params = new Vector(); params.add(new String(“Hello server.”));

Initialize the RPC C++ xmlrpc_c::clientXmlTransport_libwww xlmrpcTransport; xmlrpc_c::client_xml xmlrpcClient( &xmlrpcTransport); xmlrpc_c::rpcPtr xmlrpc( “server.sayHello”, params); xmlrpc_c::carriageParm_libwww0 cParm( “

Initialize the RPC Java XmlRpcClient client = null; try { client = new XmlRpcClient( “ } catch (MalformedURLException e) { System.err.println(e); }

Execute the RPC C++ try { xmlrpc->call(&client, &cParm); } catch (std::exception const e) { cerr << “Connection refused.” << endl; }

Execute the RPC Java try { Object returnValue = client.execute( “server.sayHello”, params); } catch (XmlRpcException e) { System.err.println(e); // some RPC problem } catch (IOException e) { System.err.println(“Connection refused.”); }

Handle errors C++ if (xmlrpc->isSuccessful() == false) { if (xmlrpc->isFinished() == true) { xmlrpc_c::fault f = xmlrpc->getFault(); if (f.getCode() == 0) {…} // exception else {…} // unexpected error } else {…} // unexpected error – can’t get fault }

Interpret Return Value C++ if (xmlrpc->isSuccessful() == true) { xmlrpc_c::value v = xmlrpc->getResult(); xmlrpc_c::value_string rpcstr = (xmlrpc_c::value_string) v; std::string text = (std::string) rpcstr; }

Interpret Return Value Java // The return value of the RPC was stored // in returnValue, which is of type Object. try { String text = (String) returnValue; } catch (ClassCastException e) { // returnValue was not a String. // It could have been an Exception. }

Creating an XML-RPC Server 1. Define one or more RPC handlers –C++: Subclass xmlrpc_c::method –Java: Create a new public class 2. Initialize the library’s server object –Provide port number on which to listen 3. Add RPC handlers to the server –Library-specific call 4. Start the server –Optionally create new thread for server

Define RPC Handlers C++ class HelloMethod : public xmlrpc_c::method { public: void execute(xmlrpc-c::paramList const& params, xmlrpc_c::value* const retvalP) { *retvalP = xmlrpc_c::value_string( “Hello client.”); } };

Define RPC Handlers Java public class RPCHandler { // All public methods in this class are // RPC handlers public String sayHello(String param) { return new String(“Hello client.”); }

Initialize the Server C++ xmlrpc_c::registry reg; xmlrpc_c::serverAbyss server; Java WebServer server = null; try { server = new WebServer(9382); } catch (Exception e) { System.err.println(e); }

Add RPC Handlers C++ xmlrpc_c::methodPtr const helloMethod( new HelloMethod); reg.addMethod(“server.sayHello”, helloMethod); server = xmlrpc_c::serverAbyss(reg, 9382, “xmlrpc.log”);

Add RPC Handlers Java server.addHandler( “server”, new RPCHandler() ); // RPC names will be “server.” followed by // the name of a public method in // RPCHandler.

Start the Server C++ // Runs in current thread. server.run(); Java // Runs in new thread. server.start();

XML-RPC