XMLRPC - PowerPoint PPT Presentation

About This Presentation
Title:

XMLRPC

Description:

Designed to leverage XML for marshalling/unmarshalling RPC calls ... Actual XML very verbose (never seen) SOAP more flexible. Data types. XML-RPC data type ... – PowerPoint PPT presentation

Number of Views:65
Avg rating:3.0/5.0
Slides: 7
Provided by: smi779
Learn more at: https://www.cs.odu.edu
Category:
Tags: xmlrpc | verbose

less

Transcript and Presenter's Notes

Title: XMLRPC


1
XML-RPC
  • Paul Flynn
  • CS775 Fall 2001
  • 6 Nov 2001

2
Background
  • Designed to leverage XML for marshalling/unmarshal
    ling RPC calls
  • Precursor to SOAP
  • Can be used with wide variety of platforms
  • Information http//www.xmlrpc.com

3
Advantages / Disadvantages
  • Simple to implement
  • Uses HTTP so can pass through firewalls
  • Mix/match clients and servers platforms
  • Limited number of types
  • Actual XML very verbose (never seen)
  • SOAP more flexible

4
Data types
5
Sample Code
  • Register Server
  • Client Setup
  • Client Use

XmlRpc.setDriver("org.apache.xerces.parsers.SAXPar
ser") WebServer server new WebServer(Integer.pa
rseInt(args0)) server.addHandler("s
tore", new StoreImpl())
XmlRpc.setDriver("org.apache.xerces.parsers.SAXPar
ser") XmlRpcClient str new XmlRpcClient(url)
Vector parnew Vector() par.addElement(uid) par.
addElement(new Integer(qty)) str.execute("store.a
ddinventory",par)
6
Client
Server
  • private void doAddnewitem (Itemstr item)
  • ByteArrayOutputStream bosnull
  • try
  • bosnew ByteArrayOutputStream()
  • ObjectOutputStream oos
  • new ObjectOutputStream(bos)
  • oos.writeObject(item)
  • oos.close()
  • Vector parnew Vector()
  • par.addElement(bos.toByteArray())
  • Boolean test (Boolean)client.execute(
  • "store.addnewitem",par))
  • if(test.booleanValue())
  • //do success
  • else
  • //do failure
  • public boolean addnewitem (byte in_item)
  • Itemstr itnull
  • try
  • ObjectInputStream ois
  • new ObjectInputStream (
  • new ByteArrayInputStream(in_item))
  • it (Itemstr)ois.readObject()
  • catch(Exception e)
  • // now call the original form of the method
  • return addnewitem(it)
  • public boolean addnewitem (Itemstr item)
  • try
  • products.put(item.uid, item)
  • catch(NullPointerException e)
  • return false
Write a Comment
User Comments (0)
About PowerShow.com