SlideShare uma empresa Scribd logo
1 de 11
Baixar para ler offline
© Peter R. Egli 2015
1/11
Rev. 1.60
XML-RPC indigoo.com
INTRODUCTION TO XML-RPC,
A SIMPLE XML-BASED RPC MECHANISM
XML-RPC
Peter R. Egli
INDIGOO.COM
© Peter R. Egli 2015
2/11
Rev. 1.60
XML-RPC indigoo.com
Contents
1. What is XML-RPC?
2. XML-RPC architecture
3. XML-RPC protocol
4. XML-RPC server implementation in Java
5. Where to use XML-RPC
© Peter R. Egli 2015
3/11
Rev. 1.60
XML-RPC indigoo.com
1. What is XML-RPC?
XML-RPC is a remote procedure call protocol using XML as data format and HTTP as transport
protocol.
Advantages of XML-RPC:
• Simple mechanism to call remote procedures on a machine with a different OS.
• XML-RPC is language and platform independent. XML-RPC libraries are available in Java
and other languages (e.g. .Net: http://xml-rpc.net/).
• XML-RPC is not more than its name implies and thus is very simple and lean (very short
specification, see http://xmlrpc.scripting.com/spec.html).
Protocols and techniques behind XML-RPC:
1. XML - Formatting of the request and response and the arguments (wire protocol)
2. RPC - Remote call of procedures.
3. HTTP - Transport protocol for the XML („firewall-friendly“).
<methodCall>
…
</methodCall>
HTTP HTTP
<methodResponse>
…
</methodResponse>
XML-
RPC
server
XML-
RPC
client
<methodCall>
…
</methodCall>
<methodResponse>
…
</methodResponse>
© Peter R. Egli 2015
4/11
Rev. 1.60
XML-RPC indigoo.com
2. XML-RPC architecture
The client application accesses the server through a URL (= location where service resides).
The XML-RPC listener receives requests and passes these to the handler (= user defined class
servicing the request).
Client
application
XML-RPC
HTTP
TCP
IP
XML-RPC
HTTP
TCP
IP
XML-RPC
Handler
XML-RPC
listener
service.method call
response
XML request
XML reply
HTTP POST
HTTP reply
© Peter R. Egli 2015
5/11
Rev. 1.60
XML-RPC indigoo.com
3. XML-RPC protocol (1/5)
Request (example from www.xmlrpc.com/spec):
• The XML body of the HTTP request contains a single method call (getStateName).
• The method is called on a service name under which the method is available.
• The URL does not need to be specified (service is indicated by the string before the dot
in the method name element).
POST /RPC2 HTTP/1.0
User-Agent: Frontier/5.1.2 (WinNT)
Host: betty.userland.com
Content-Type: text/xml
Content-length: 181
<?xml version="1.0"?>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
<param>
<value>
<i4>41</i4>
</value>
</param>
</params>
</methodCall>
HTTP header (request)
with required header fields (blue)
XML body
List of request
parameters
© Peter R. Egli 2015
6/11
Rev. 1.60
XML-RPC indigoo.com
List of
return
values
3. XML-RPC protocol (2/5)
Response (example from www.xmlrpc.com/spec):
• The HTTP return code is always „200 OK“, even in case of an XML-RPC fault (see below).
• The response contains a single value (like a return argument of a local procedure call).
HTTP/1.1 200 OK
Connection: close
Content-Length: 158
Content-Type: text/xml
Date: Fri, 17 Jul 1998 19:55:08 GMT
Server: UserLand Frontier/5.1.2-WinNT
<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<string>South Dakota</string>
</value>
</param>
</params>
</methodResponse>
HTTP header (response)
with required header fields (blue)
XML body
© Peter R. Egli 2015
7/11
Rev. 1.60
XML-RPC indigoo.com
3. XML-RPC protocol (3/5)
Response with a failure (example from www.xmlrpc.com/spec):
• Even in case of an XML-RPC level failure the HTTP return code is 200 OK.
• The failure is indicated with the <fault> element.
HTTP/1.1 200 OK
Connection: close
Content-Length: 426
Content-Type: text/xml
Date: Fri, 17 Jul 1998 19:55:02 GMT
Server: UserLand Frontier/5.1.2-WinNT
<?xml version="1.0"?>
<methodResponse>
<fault>
<value>
<struct>
<member><name>faultCode</name><value><int>4</int></value></member>
<member><name>faultString</name>
<value><string>Too many parameters.</string>
</value>
</member>
</struct>
</value>
</fault>
</methodResponse>
© Peter R. Egli 2015
8/11
Rev. 1.60
XML-RPC indigoo.com
3. XML-RPC protocol (4/5)
Parameter types (1/2):
Base types:
XML-RPC has a very limited set of base types:
Type Description Example
<i4> or <int> Four-byte signed integer -12
<boolean> 0 (false) or 1 (true) 1
<string> ASCII string (string is default) Hi!
<double> Double-precision 3.1415
<dateTime.iso8601> Date/time 19980717T14:08:55
<base64> Base64-encoded binary eW91IGNhbid
Structs:
Structs contain elements (<member>) with a <name> and <value> element ("named" values).
Structs may be recursive (value in a struct may be a struct again).
<struct>
<member>
<name>lowerBound</name>
<value><i4>18</i4></value>
</member>
<member>
<name>upperBound</name>
<value><i4>139</i4></value>
</member>
</struct>
© Peter R. Egli 2015
9/11
Rev. 1.60
XML-RPC indigoo.com
3. XML-RPC protocol (5/5)
Parameter types (2/2):
Arrays:
An array contains a single <data> element that in turn contains an array of <value> elements.
An array differs from a struct in that its elements are simple values (without <name> element).
Arrays may be recursive (value in array may be an array or also a struct).
<array>
<data>
<value><i4>12</i4></value>
<value><string>Egypt</string></value>
<value><boolean>0</boolean></value>
<value><i4>-31</i4></value>
</data>
</array>
© Peter R. Egli 2015
10/11
Rev. 1.60
XML-RPC indigoo.com
4. XML-RPC server implementation in Java
The class loader provides lookup service (find the serving class from request name).
The XML-RPC listener does unmarshalling / marshalling of parameters.
The XML-RPC handler is the user class that handles the request (implementation of the
actual procedure call).
WebServer
XML-RPC
listener
Classloader
properties
Load mapping into
class loader
XML-RPC
handler
(user class)
Defines the mapping
from service name
to class name serving
the requests
HTTP protocol
front-end
Passes the request to
the XML-RPC server
Consults class
loader to get
the serving class
Unpack the XML, get the serving
class, convert the arguments (C  S)
Pack the response into XML (S  C)
Pass the request
to the serving
class
HTTP
© Peter R. Egli 2015
11/11
Rev. 1.60
XML-RPC indigoo.com
5. Where to use XML-RPC
• XML-RPC may be suited for simple applications or situations where clients implemented in
different technologies need to interact with a server with simple read-write operations where
a more complex middleware technology would be overkill.
• XML-RPC is a solution to integrate different platforms with a simple middleware.
• XML-RPC is very simple so it can be implemented also for platforms without open source or
commercially available XML-RPC libraries.
Java
PL/1
C++
RMI / IIOP
CORBA
DCOM
CORBA
runtime
DCOM
runtime
C++
Integration of different
platforms leads to complexity
on the server side
Java
PL/1
C++
XML-RPC
runtime
C++ XML-RPC as a common integration
technology reduces complexity on
the server side (but adds complexity
on the client side)
XML-RPC
stub
HTTP

Mais conteúdo relacionado

Mais procurados

Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
Krazy Koder
 
Java servlets
Java servletsJava servlets
Java servlets
lopjuan
 

Mais procurados (20)

Php
PhpPhp
Php
 
Html 5 geolocation api
Html 5 geolocation api Html 5 geolocation api
Html 5 geolocation api
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Introduction to Android
Introduction to Android Introduction to Android
Introduction to Android
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Common Gateway Interface
Common Gateway InterfaceCommon Gateway Interface
Common Gateway Interface
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
 
Web Services
Web ServicesWeb Services
Web Services
 
Front end development session1
Front end development session1Front end development session1
Front end development session1
 
Web services SOAP
Web services SOAPWeb services SOAP
Web services SOAP
 
REST API Basics
REST API BasicsREST API Basics
REST API Basics
 
IRJET - College Enquiry Chatbot
IRJET - College Enquiry ChatbotIRJET - College Enquiry Chatbot
IRJET - College Enquiry Chatbot
 
Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django framework
 
Open Source Ajax Solution @OSDC.tw 2009
Open Source Ajax  Solution @OSDC.tw 2009Open Source Ajax  Solution @OSDC.tw 2009
Open Source Ajax Solution @OSDC.tw 2009
 
Java servlets
Java servletsJava servlets
Java servlets
 
Web server class diagram
Web server class diagramWeb server class diagram
Web server class diagram
 
Difference between frontend and backend
Difference between frontend and backendDifference between frontend and backend
Difference between frontend and backend
 
What is an API?
What is an API?What is an API?
What is an API?
 

Destaque (6)

Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and REST
 
SOAP vs REST
SOAP vs RESTSOAP vs REST
SOAP vs REST
 
Web services - A Practical Approach
Web services - A Practical ApproachWeb services - A Practical Approach
Web services - A Practical Approach
 
Mule ESB
Mule ESBMule ESB
Mule ESB
 
Matrimonial web site Documentation
Matrimonial web site DocumentationMatrimonial web site Documentation
Matrimonial web site Documentation
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentation
 

Semelhante a XML-RPC (XML Remote Procedure Call)

Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Marco Gralike
 

Semelhante a XML-RPC (XML Remote Procedure Call) (20)

xml rpc
xml rpcxml rpc
xml rpc
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
 
Boost Your Content Strategy for REST APIs with Gururaj BS
Boost Your Content Strategy for REST APIs with Gururaj BSBoost Your Content Strategy for REST APIs with Gururaj BS
Boost Your Content Strategy for REST APIs with Gururaj BS
 
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful  Protocol BuffersJavaOne 2009 - TS-5276 - RESTful  Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
 
Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
 
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
 
Tibco business works
Tibco business worksTibco business works
Tibco business works
 
Best practices for large oracle apps r12 implementations apps14
Best practices for large oracle apps r12 implementations apps14Best practices for large oracle apps r12 implementations apps14
Best practices for large oracle apps r12 implementations apps14
 
HTTP Basic
HTTP BasicHTTP Basic
HTTP Basic
 
Bt0083 server side programing 2
Bt0083 server side programing  2Bt0083 server side programing  2
Bt0083 server side programing 2
 
Lambdas and Laughs
Lambdas and LaughsLambdas and Laughs
Lambdas and Laughs
 
Servlet 3.0
Servlet 3.0Servlet 3.0
Servlet 3.0
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Network basics
Network basicsNetwork basics
Network basics
 
JAX-RS.next
JAX-RS.nextJAX-RS.next
JAX-RS.next
 
Build a Micro HTTP Server for Embedded System
Build a Micro HTTP Server for Embedded SystemBuild a Micro HTTP Server for Embedded System
Build a Micro HTTP Server for Embedded System
 
Play framework : A Walkthrough
Play framework : A WalkthroughPlay framework : A Walkthrough
Play framework : A Walkthrough
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
 
Micro HTTP Server for Embedded
Micro HTTP Server for EmbeddedMicro HTTP Server for Embedded
Micro HTTP Server for Embedded
 

Mais de Peter R. Egli

Mais de Peter R. Egli (20)

LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M ScenariosLPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
 
Data Networking Concepts
Data Networking ConceptsData Networking Concepts
Data Networking Concepts
 
Communication middleware
Communication middlewareCommunication middleware
Communication middleware
 
Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)
 
Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)
 
Microsoft .NET Platform
Microsoft .NET PlatformMicrosoft .NET Platform
Microsoft .NET Platform
 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud Computing
 
MQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message QueueingMQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message Queueing
 
Enterprise Application Integration Technologies
Enterprise Application Integration TechnologiesEnterprise Application Integration Technologies
Enterprise Application Integration Technologies
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technology
 
Android Native Development Kit
Android Native Development KitAndroid Native Development Kit
Android Native Development Kit
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)
 
Web services
Web servicesWeb services
Web services
 
Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message Queueing
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBA
 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging Service
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

XML-RPC (XML Remote Procedure Call)

  • 1. © Peter R. Egli 2015 1/11 Rev. 1.60 XML-RPC indigoo.com INTRODUCTION TO XML-RPC, A SIMPLE XML-BASED RPC MECHANISM XML-RPC Peter R. Egli INDIGOO.COM
  • 2. © Peter R. Egli 2015 2/11 Rev. 1.60 XML-RPC indigoo.com Contents 1. What is XML-RPC? 2. XML-RPC architecture 3. XML-RPC protocol 4. XML-RPC server implementation in Java 5. Where to use XML-RPC
  • 3. © Peter R. Egli 2015 3/11 Rev. 1.60 XML-RPC indigoo.com 1. What is XML-RPC? XML-RPC is a remote procedure call protocol using XML as data format and HTTP as transport protocol. Advantages of XML-RPC: • Simple mechanism to call remote procedures on a machine with a different OS. • XML-RPC is language and platform independent. XML-RPC libraries are available in Java and other languages (e.g. .Net: http://xml-rpc.net/). • XML-RPC is not more than its name implies and thus is very simple and lean (very short specification, see http://xmlrpc.scripting.com/spec.html). Protocols and techniques behind XML-RPC: 1. XML - Formatting of the request and response and the arguments (wire protocol) 2. RPC - Remote call of procedures. 3. HTTP - Transport protocol for the XML („firewall-friendly“). <methodCall> … </methodCall> HTTP HTTP <methodResponse> … </methodResponse> XML- RPC server XML- RPC client <methodCall> … </methodCall> <methodResponse> … </methodResponse>
  • 4. © Peter R. Egli 2015 4/11 Rev. 1.60 XML-RPC indigoo.com 2. XML-RPC architecture The client application accesses the server through a URL (= location where service resides). The XML-RPC listener receives requests and passes these to the handler (= user defined class servicing the request). Client application XML-RPC HTTP TCP IP XML-RPC HTTP TCP IP XML-RPC Handler XML-RPC listener service.method call response XML request XML reply HTTP POST HTTP reply
  • 5. © Peter R. Egli 2015 5/11 Rev. 1.60 XML-RPC indigoo.com 3. XML-RPC protocol (1/5) Request (example from www.xmlrpc.com/spec): • The XML body of the HTTP request contains a single method call (getStateName). • The method is called on a service name under which the method is available. • The URL does not need to be specified (service is indicated by the string before the dot in the method name element). POST /RPC2 HTTP/1.0 User-Agent: Frontier/5.1.2 (WinNT) Host: betty.userland.com Content-Type: text/xml Content-length: 181 <?xml version="1.0"?> <methodCall> <methodName>examples.getStateName</methodName> <params> <param> <value> <i4>41</i4> </value> </param> </params> </methodCall> HTTP header (request) with required header fields (blue) XML body List of request parameters
  • 6. © Peter R. Egli 2015 6/11 Rev. 1.60 XML-RPC indigoo.com List of return values 3. XML-RPC protocol (2/5) Response (example from www.xmlrpc.com/spec): • The HTTP return code is always „200 OK“, even in case of an XML-RPC fault (see below). • The response contains a single value (like a return argument of a local procedure call). HTTP/1.1 200 OK Connection: close Content-Length: 158 Content-Type: text/xml Date: Fri, 17 Jul 1998 19:55:08 GMT Server: UserLand Frontier/5.1.2-WinNT <?xml version="1.0"?> <methodResponse> <params> <param> <value> <string>South Dakota</string> </value> </param> </params> </methodResponse> HTTP header (response) with required header fields (blue) XML body
  • 7. © Peter R. Egli 2015 7/11 Rev. 1.60 XML-RPC indigoo.com 3. XML-RPC protocol (3/5) Response with a failure (example from www.xmlrpc.com/spec): • Even in case of an XML-RPC level failure the HTTP return code is 200 OK. • The failure is indicated with the <fault> element. HTTP/1.1 200 OK Connection: close Content-Length: 426 Content-Type: text/xml Date: Fri, 17 Jul 1998 19:55:02 GMT Server: UserLand Frontier/5.1.2-WinNT <?xml version="1.0"?> <methodResponse> <fault> <value> <struct> <member><name>faultCode</name><value><int>4</int></value></member> <member><name>faultString</name> <value><string>Too many parameters.</string> </value> </member> </struct> </value> </fault> </methodResponse>
  • 8. © Peter R. Egli 2015 8/11 Rev. 1.60 XML-RPC indigoo.com 3. XML-RPC protocol (4/5) Parameter types (1/2): Base types: XML-RPC has a very limited set of base types: Type Description Example <i4> or <int> Four-byte signed integer -12 <boolean> 0 (false) or 1 (true) 1 <string> ASCII string (string is default) Hi! <double> Double-precision 3.1415 <dateTime.iso8601> Date/time 19980717T14:08:55 <base64> Base64-encoded binary eW91IGNhbid Structs: Structs contain elements (<member>) with a <name> and <value> element ("named" values). Structs may be recursive (value in a struct may be a struct again). <struct> <member> <name>lowerBound</name> <value><i4>18</i4></value> </member> <member> <name>upperBound</name> <value><i4>139</i4></value> </member> </struct>
  • 9. © Peter R. Egli 2015 9/11 Rev. 1.60 XML-RPC indigoo.com 3. XML-RPC protocol (5/5) Parameter types (2/2): Arrays: An array contains a single <data> element that in turn contains an array of <value> elements. An array differs from a struct in that its elements are simple values (without <name> element). Arrays may be recursive (value in array may be an array or also a struct). <array> <data> <value><i4>12</i4></value> <value><string>Egypt</string></value> <value><boolean>0</boolean></value> <value><i4>-31</i4></value> </data> </array>
  • 10. © Peter R. Egli 2015 10/11 Rev. 1.60 XML-RPC indigoo.com 4. XML-RPC server implementation in Java The class loader provides lookup service (find the serving class from request name). The XML-RPC listener does unmarshalling / marshalling of parameters. The XML-RPC handler is the user class that handles the request (implementation of the actual procedure call). WebServer XML-RPC listener Classloader properties Load mapping into class loader XML-RPC handler (user class) Defines the mapping from service name to class name serving the requests HTTP protocol front-end Passes the request to the XML-RPC server Consults class loader to get the serving class Unpack the XML, get the serving class, convert the arguments (C  S) Pack the response into XML (S  C) Pass the request to the serving class HTTP
  • 11. © Peter R. Egli 2015 11/11 Rev. 1.60 XML-RPC indigoo.com 5. Where to use XML-RPC • XML-RPC may be suited for simple applications or situations where clients implemented in different technologies need to interact with a server with simple read-write operations where a more complex middleware technology would be overkill. • XML-RPC is a solution to integrate different platforms with a simple middleware. • XML-RPC is very simple so it can be implemented also for platforms without open source or commercially available XML-RPC libraries. Java PL/1 C++ RMI / IIOP CORBA DCOM CORBA runtime DCOM runtime C++ Integration of different platforms leads to complexity on the server side Java PL/1 C++ XML-RPC runtime C++ XML-RPC as a common integration technology reduces complexity on the server side (but adds complexity on the client side) XML-RPC stub HTTP