XML-RPC Cvičení 8 - DS 2006. Úvod XML RPC Volání vzdálených podprogramů.

Slides:



Advertisements
Similar presentations
Graohics CSC 171 FALL 2001 LECTURE 16. History: COBOL Conference on Data System Languages (CODASYL) - led by Joe Wegstein of NBS developed the.
Advertisements

Software Engineering Implementation Lecture 3 ASPI8-4 Anders P. Ravn, Feb 2004.
1 SSD3 - Unit 2 Java toString & Equals Presentation Class Website:
User Interfaces File I/O and Exceptions (c) IDMS/SQL News
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.
Lecture 27 Exceptions COMP1681 / SE15 Introduction to Programming.
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.
Java Threads A tool for concurrency. OS schedules processes Ready Running 200 Blocked A process loses the CPU and another.
Internetworking (Contd) Chapter 4. Figure 3.26 ATM protocol layers.
Exceptions Problems with error reporting so far –Either ignored exceptions or terminated program on first error. –Error handling and regular code mixed.
SELECTION CSC 171 FALL 2004 LECTURE 8. Sequences start end.
Exceptions Problems with error reporting so far –Either ignored exceptions or terminated program on first error. –Error handling and regular code mixed.
Networking java.net package, which provides support for networking. Its creators have called Java “programming for the Internet.” Socket :- A network socket.
CSE 341, S. Tanimoto Java networking- 1 Java Networking Motivation Network Layers Using Sockets A Tiny Server Applets URLs Downloading Images, MediaTracker.
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
Example 1 :- Handling integer values public class Program1 { public static void main(String [] args) { int value1, value2, sum; value1 = Integer.parseInt(args[0]);
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.
Socket programming 1. getByName import java.net.*; public class GetHostName { public static void main (String args[]) { String host = "
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
1 EIE424 Distributed Systems and Networking Programming –Part II 2. XML-RPC.
Remote Procedure Calls Babak Esfandiari. RPC Introduced by Birrell & Nelson (1984) Remote Procedure Calls allow a program to make use of procedures executing.
Import java.net.*; import java.io.*; public class LowPortScanner { public static void main(String[] args) { String host = "localhost"; if (args.length.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Exceptions. Exception Abnormal event occurring during program execution Examples –Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
1 Streams Files are a computer’s long term memory Need ability for programs to –get information from files –copy information from program variables to.
Servlet Communication Other Servlets, HTML pages, objects shared among servlets on same server Servlets on another server with HTTP request of the other.
Object Oriented Programming in Java Lecture 16. Networking in Java Concepts Technicalities in java.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 23 — Simple Object Access Protocol (SOAP) and Microsoft BizTalk™ Outline 23.1Introduction 23.2Simple.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
1 cs205: engineering software university of virginia fall 2006 Network Programming* * Just enough to make you dangerous Bill Cheswick’s map of the Internet.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
CliServ. J2EE/141 Client/Server Distributed Systems v Objectives –introduce the J2EE specification, and the J2EE SDK –other approaches: Struts,
CS603 Communication Mechanisms: SOAP 25 January 2002.
IBM TSpaces Lab 3 Transactions Event Registration.
By Vivek Dimri. Basic Concepts on Networking IP Address – Protocol – Ports – The Client/Server Paradigm – Sockets The Java Networking Package – The InetAddress.
Exceptions. Exception  Abnormal event occurring during program execution  Examples Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
Files Review For output to a file: –FileOutputStream variable initialized to filename (String) and append/not append (boolean) –PrintWriter variable initialized.
Java Programming II Java Network (I) Java Programming II.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
ClaRA web services V. Gyurjyan Clas12 Software Meeting
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Starting Out with Java: From Control Structures through Objects 5 th edition By Tony Gaddis Source Code: Chapter 5.
CSE 4939 Alex Riordan Brian Pruitt-Goddard. Design an interactive source control application that works between an android phone and a project located.
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
Netprog Java RMI1 Remote Method Invocation.
Object Oriented Programming Lecture 2: BallWorld.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Methods Matthew Harrison. Overview ● There are five main aspects of methods... ● 1) Modifiers – public, private ● 2) Method Name ● 3) Parameters ● 4)
Echo Networking COMP
Chapter 10 – Exception Handling
using System; namespace Demo01 { class Program
CSE 341, S. Tanimoto Java networking-
Sum of natural numbers class SumOfNaturalNumbers {
RADE new features via JAVA
PRESENTED To: Sir Abid………. PRESENTED BY: Insharah khan………. SUBJECT:
Testing and Exceptions
Java Network Programming
XML-RPC a lightweight data communication protocol
Decision statements. - They can use logic to arrive at desired results
An Introduction to Java – Part I, language basics
CIS Distributed and Parallel Architectures
Java Lesson 36 Mr. Kalmes.
Recursive GCD Demo public class Euclid {
class PrintOnetoTen { public static void main(String args[]) {
Object Oriented Programming
Exceptions.
Exceptions.
Presentation transcript:

XML-RPC Cvičení 8 - DS 2006

Úvod XML RPC Volání vzdálených podprogramů

XML typy XML-RPC typeSimplest Java typeMore complex Java type i4intjava.lang.Integer int java.lang.Integer boolean java.lang.Boolean stringjava.lang.String double java.lang.Double dateTime.iso8601java.util.Date structjava.util.Hashtable arrayjava.util.Vector base64byte[] nil (extension)null

Klient public class GetSetClient { public static void main(String args[]) { if (args.length < 1) { System.out.println( "Usage: java GetSetClient [get | set] [value]"); System.exit(-1); } String getOrSet=new String(args[0]); if (!((getOrSet.equals("get")) || (getOrSet.equals("set")))) { System.out.println( "First argument must be get or set"); System.exit(-1); }

Klient try { // Create the client, identifying the server XmlRpcClient client = new XmlRpcClient(" //get local host IP address InetAddress address=InetAddress.getLocalHost( ); String ipAddress=address.toString( ); // Create the request parameters using user input Vector params = new Vector( ); params.addElement(ipAddress); if (getOrSet.equals("set")) { Integer newValue=new Integer(args[1]); params.addElement(newValue); }

Klient // Issue a request Object result=null; if (getOrSet.equals("set")) { result = client.execute("getSet.setValue", params); } else { result = client.execute("getSet.getValue", params); } // Report the results System.out.println("The response was: " + result.toString( )); } catch (IOException e) { System.out.println("IO Exception: " + e.getMessage( )); } catch (XmlRpcException e) { System.out.println("Exception within XML-RPC: " + e.getMessage( )); }

Server public class GetSetServer { public static void main(String[] args) { if (args.length < 1) { System.out.println( "Usage: java GetSetServer [port]"); System.exit(-1); } try { // Start the server, using built-in version System.out.println("Attempting to start XML-RPC Server..."); WebServer server = new WebServer(Integer.parseInt(args[0]));

Server // Register our handler class as area server.addHandler("getSet", new GetSetHandler(20)); System.out.println( "Registered GetSetHandler class to getSet."); System.out.println("Now accepting requests. (Halt program to stop.)"); } catch (IOException e) { System.out.println("Could not start server: " + e.getMessage( )); }

Handler public class GetSetHandler { protected int value; public GetSetHandler(int initialValue) { value=initialValue; } public int getValue(String requester) { return value; } public int setValue(String requester, int newValue) { value=newValue; return value; }

Download Jakarta Commons - The Commons is a Jakarta subproject focused on all aspects of reusable Java components. Commons Proper - A repository of reusable Java components. Commons Codec - General encoding/decoding algorithms (for example phonetic, base64, URL). ons-codec-1.3.zip