XEP-0009: Jabber-RPC

Abstract
This specification defines an XMPP protocol extension for transporting XML-RPC encoded requests and responses between two XMPP entities. The protocol supports all syntax and semantics of XML-RPC except that it uses XMPP instead of HTTP as the underlying transport.
Author
DJ Adams
Copyright
© 2001 – 2021 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

Final

NOTICE: The protocol defined herein is a Final Standard of the XMPP Standards Foundation and can be considered a stable technology for implementation and deployment.
Type
Standards Track
Version
2.2.1 (2021-03-04)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Stable
  4. Final

1. Introduction

XML-RPC [1] is a method of encoding RPC requests and responses in XML. The original specification defines HTTP (see RFC 2068 [2]) as the only valid transport for XML-RPC payloads.

Various initiatives exist already to transport XML-RPC payloads over Jabber. These initiatives were independent of each other and used slightly differing methods (e.g. carrying the payload in a <message/> element as opposed to an <iq/> stanza), resulting in potential interoperability problems.

A working session during JabberCon 2001 resulted in formalisation of a single method. This document describes that method, which is labelled as Jabber-RPC to differentiate it from XML-RPC itself.

2. Jabber-RPC

The <iq/> stanza is used to transport XML-RPC payloads. XML-RPC requests are transported using an <iq/> stanza of type "set", and XML-RPC responses are transported using an <iq/> stanza of type "result". An <iq/> stanza MUST NOT contain more than one request or response.

The <iq/> stanza contains a single <query/> sub-element in the jabber:iq:rpc namespace. The direct child of the <query/> element will be either a single <methodCall/> element (in the case of a request) or a single <methodResponse/> element (in the case of a response). This child element will contain the XML-RPC payload. Note that the XML declaration that normally appears at the head of an XML-RPC request or response when transported as the payload of an HTTP POST request MUST BE omitted when it is transported via a Jabber <iq/> stanza.

The encoding of the Jabber XML stream is UTF-8. It is assumed that the encoding of the XML-RPC payload is also UTF-8.

Application-level errors will be indicated within the XML-RPC payload (as is the case with the traditional HTTP-based XML-RPC mechanism). Transport level errors will be indicated in the normal way for <iq/> stanzas -- namely, by an <iq/> stanza of type "error" and the addition of an <error/> tag as a direct child of the <iq/> stanza. There are no specific XML-RPC-related, transport-level errors.

In September of 2011, it was discovered that the XML schema quoted in Section 8 contains an error, showing a child element of <Base64/> (uppercase "B") instead of <base64/> (lowercase "b"). A review of the XML-RPC specification and of numerous XML-RPC and Jabber-RPC implementations showed that the element name is properly "base64" and that the quoted schema was in error by having an element name of "Base64". Therefore this specification and its associated schema were modified to use the correct element name: "base64". It is possible that some existing Jabber-RPC implementations might send a child element of <Base64/>.

3. Examples

Example 1. A typical request
<iq type='set'
    from='requester@company-b.com/jrpc-client'
    to='responder@company-a.com/jrpc-server'
    id='rpc1'>
  <query xmlns='jabber:iq:rpc'>
    <methodCall>
      <methodName>examples.getStateName</methodName>
      <params>
        <param>
          <value><i4>6</i4></value>
        </param>
      </params>
    </methodCall>
  </query>
</iq>
Example 2. A typical response
<iq type='result'
    from='responder@company-a.com/jrpc-server'
    to='requester@company-b.com/jrpc-client'
    id='rpc1'>
  <query xmlns='jabber:iq:rpc'>
    <methodResponse>
      <params>
        <param>
          <value><string>Colorado</string></value>
        </param>
      </params>
    </methodResponse>
  </query>
</iq>

If the requesting entity does not have sufficient permissions to perform remote procedure calls, the responding entity MUST return a <forbidden/> error:

Example 3. Requesting entity is forbidden to perform remote procedure calls
<iq type='error'
    from='responder@company-a.com/jrpc-server'
    to='requester@company-b.com/jrpc-client'
    id='rpc1'>
  <query xmlns='jabber:iq:rpc'>
    <methodCall>
      <methodName>examples.getStateName</methodName>
      <params>
        <param>
          <value><i4>6</i4></value>
        </param>
      </params>
    </methodCall>
  </query>
  <error code='403' type='auth'>
    <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>

4. Service Discovery

If an entity supports the Jabber-RPC protocol, it SHOULD advertise that fact in response to Service Discovery (XEP-0030) [3] information ("diso#info") requests by returning an identity of "automation/rpc" and a feature of "jabber:iq:rpc":

Example 4. A disco#info query
<iq type='get'
    from='requester@company-b.com/jrpc-client'
    to='responder@company-a.com/jrpc-server'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
Example 5. A disco#info response
<iq type='result'
    to='requester@company-b.com/jrpc-client'
    from='responder@company-a.com/jrpc-server'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <identity category='automation' type='rpc'/>
    <feature var='jabber:iq:rpc'/>
  </query>
</iq>

5. Security Considerations

An entity that supports Jabber-RPC SHOULD establish a permitted list of entities that are allowed to perform remote procedure calls and MUST return a <forbidden/> error if entities with insufficient permissions attempt such calls.

6. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [4].

7. XMPP Registrar Considerations

7.1 Protocol Namespaces

The XMPP Registrar [5] includes 'jabber:iq:rpc' in its registry of protocol namespaces.

7.2 Service Discovery Identity

The XMPP Registrar includes a Service Discovery type of "rpc" within the "automation" category in its registry of service discovery identities.

8. XML Schema

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='jabber:iq:rpc'
    xmlns='jabber:iq:rpc'
    elementFormDefault='qualified'>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-0009: http://www.xmpp.org/extensions/xep-0009.html

      There is no official XML schema for XML-RPC. The main body
      of this schema has been borrowed from an unofficial schema
      representation contained in the book "Processing XML With
      Java" by Elliotte Rusty Harold, as located at:

      http://www.ibiblio.org/xml/books/xmljava/chapters/ch02s05.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='query'>
    <xs:complexType>
      <xs:choice minOccurs='0' maxOccurs='1'>
        <xs:element ref='methodCall'/>
        <xs:element ref='methodResponse'/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="methodCall">
    <xs:complexType>
      <xs:all>
        <xs:element name="methodName">
          <xs:simpleType>
            <xs:restriction base="ASCIIString">
              <xs:pattern value="([A-Za-z0-9]|/|\.|:|_)*" />
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element name="params" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="param"  type="ParamType"
                           minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
          </xs:complexType>
         </xs:element>
      </xs:all>
    </xs:complexType>
  </xs:element>

  <xs:element name="methodResponse">
    <xs:complexType>
      <xs:choice>
        <xs:element name="params">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="param" type="ParamType"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="fault">
          <!-- What can appear inside a fault is very restricted -->
          <xs:complexType>
            <xs:sequence>
              <xs:element name="value">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="struct">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="member"
                                       type="MemberType">
                          </xs:element>
                          <xs:element name="member"
                                       type="MemberType">
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
         </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="ParamType">
    <xs:sequence>
      <xs:element name="value" type="ValueType"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ValueType" mixed="true">
    <xs:choice>
      <xs:element name="i4"            type="xs:int"/>
      <xs:element name="int"           type="xs:int"/>
      <xs:element name="string"        type="ASCIIString"/>
      <xs:element name="double"        type="xs:decimal"/>
      <xs:element name="base64"        type="xs:base64Binary">
        <xs:annotation>
          <xs:documentation>
            Corrected from "Base64" to "base64" in version 2.2 of XEP-0009.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="boolean"       type="NumericBoolean"/>
      <xs:element name="dateTime.iso8601" type="xs:dateTime"/>
      <xs:element name="array"         type="ArrayType"/>
      <xs:element name="struct"        type="StructType"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="StructType">
    <xs:sequence>
      <xs:element name="member" type="MemberType"
                   maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="MemberType">
    <xs:sequence>
      <xs:element name="name"  type="xs:string" />
      <xs:element name="value" type="ValueType"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayType">
    <xs:sequence>
      <xs:element name="data">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="value"  type="ValueType"
                         minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:simpleType name="ASCIIString">
    <xs:restriction base="xs:string">
      <xs:pattern value="([ -~]|\n|\r|\t)*" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="NumericBoolean">
    <xs:restriction base="xs:boolean">
      <xs:pattern value="0|1" />
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

Appendices

Appendix A: Document Information

Series
XEP
Number
0009
Publisher
XMPP Standards Foundation
Status
Final
Type
Standards Track
Version
2.2.1
Last Updated
2021-03-04
Approving Body
XMPP Council
Dependencies
XMPP Core, XML-RPC
Supersedes
None
Superseded By
None
Short Name
jabber-rpc
Schema
<http://xmpp.org/schemas/jabber-rpc.xsd>
Source Control
HTML

This document in other formats: XML  PDF

Appendix B: Author Information

DJ Adams
Email
dj.adams@pobox.com
JabberID
dj@gnu.mine.nu

Copyright

This XMPP Extension Protocol is copyright © 1999 – 2024 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.

Errata can be sent to <editor@xmpp.org>.

Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".

Appendix G: Notes

1. XML-RPC <http://www.xmlrpc.com/spec>.

2. RFC 2068: Hypertext Transport Protocol -- HTTP/1.1 <http://tools.ietf.org/html/rfc2068>.

3. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.

4. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.

5. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <https://xmpp.org/registrar/>.

Appendix H: Revision History

Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/

  1. Version 2.2.1 (2021-03-04)

    Cross-document editorial adjustments for inclusive language.

    mw
  2. Version 2.2 (2011-11-10)
    Corrected element name in XML schema from "Base64" to "base64".
    psa
  3. Version 2.1 (2006-02-09)
    Defined error handling, service discovery, security considerations, and XMPP Registrar considerations.
    psa
  4. Version 2.0 (2002-12-09)
    Per a vote of the Jabber Council, changed status to Final.
    psa
  5. Version 1.0 (2001-09-27)
    Changed status to Draft
    psa
  6. Version 0.1 (2001-09-14)
    Initial version
    dja

Appendix I: Bib(La)TeX Entry

@report{adams2001jabber-rpc,
  title = {Jabber-RPC},
  author = {Adams, DJ},
  type = {XEP},
  number = {0009},
  version = {2.2.1},
  institution = {XMPP Standards Foundation},
  url = {https://xmpp.org/extensions/xep-0009.html},
  date = {2001-09-14/2021-03-04},
}

END