No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0009.xml 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Jabber-RPC</title>
  10. <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.</abstract>
  11. &LEGALNOTICE;
  12. <number>0009</number>
  13. <status>Final</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XML-RPC</spec>
  19. </dependencies>
  20. <supersedes/>
  21. <supersededby/>
  22. <shortname>jabber-rpc</shortname>
  23. <schemaloc>
  24. <url>http://xmpp.org/schemas/jabber-rpc.xsd</url>
  25. </schemaloc>
  26. <author>
  27. <firstname>DJ</firstname>
  28. <surname>Adams</surname>
  29. <email>dj.adams@pobox.com</email>
  30. <jid>dj@gnu.mine.nu</jid>
  31. </author>
  32. <revision>
  33. <version>2.2</version>
  34. <date>2011-11-10</date>
  35. <initials>psa</initials>
  36. <remark>Corrected element name in XML schema from "Base64" to "base64".</remark>
  37. </revision>
  38. <revision>
  39. <version>2.1</version>
  40. <date>2006-02-09</date>
  41. <initials>psa</initials>
  42. <remark>Defined error handling, service discovery, security considerations, and XMPP Registrar considerations.</remark>
  43. </revision>
  44. <revision>
  45. <version>2.0</version>
  46. <date>2002-12-09</date>
  47. <initials>psa</initials>
  48. <remark>Per a vote of the Jabber Council, changed status to Final.</remark>
  49. </revision>
  50. <revision>
  51. <version>1.0</version>
  52. <date>2001-09-27</date>
  53. <initials>psa</initials>
  54. <remark>Changed status to Draft</remark>
  55. </revision>
  56. <revision>
  57. <version>0.1</version>
  58. <date>2001-09-14</date>
  59. <initials>dja</initials>
  60. <remark>Initial version</remark>
  61. </revision>
  62. </header>
  63. <section1 topic='Introduction'>
  64. <p>&xmlrpc; is a method of encoding RPC requests and responses in XML. The original specification defines HTTP (see &rfc2068;) as the only valid transport for XML-RPC payloads.</p>
  65. <p>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 &lt;message/&gt; element as opposed to an &IQ; stanza), resulting in potential interoperability problems.</p>
  66. <p>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.</p>
  67. </section1>
  68. <section1 topic='Jabber-RPC'>
  69. <p>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.</p>
  70. <p>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 &lt;methodCall/&gt; element (in the case of a request) or a single &lt;methodResponse/&gt; 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.</p>
  71. <p>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.</p>
  72. <p>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 &lt;error/&gt; tag as a direct child of the &IQ; stanza. There are no specific XML-RPC-related, transport-level errors.</p>
  73. <p class='box'>In September of 2011, it was discovered that the XML schema quoted in <link url='#schema'>Section 8</link> contains an error, showing a child element of &lt;Base64/&gt; (uppercase "B") instead of &lt;base64/&gt; (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 &lt;Base64/&gt;.</p>
  74. </section1>
  75. <section1 topic='Examples'>
  76. <example caption='A typical request'><![CDATA[
  77. <iq type='set'
  78. from='requester@company-b.com/jrpc-client'
  79. to='responder@company-a.com/jrpc-server'
  80. id='rpc1'>
  81. <query xmlns='jabber:iq:rpc'>
  82. <methodCall>
  83. <methodName>examples.getStateName</methodName>
  84. <params>
  85. <param>
  86. <value><i4>6</i4></value>
  87. </param>
  88. </params>
  89. </methodCall>
  90. </query>
  91. </iq>
  92. ]]></example>
  93. <example caption='A typical response'><![CDATA[
  94. <iq type='result'
  95. from='responder@company-a.com/jrpc-server'
  96. to='requester@company-b.com/jrpc-client'
  97. id='rpc1'>
  98. <query xmlns='jabber:iq:rpc'>
  99. <methodResponse>
  100. <params>
  101. <param>
  102. <value><string>Colorado</string></value>
  103. </param>
  104. </params>
  105. </methodResponse>
  106. </query>
  107. </iq>
  108. ]]></example>
  109. <p>If the requesting entity does not have sufficient permissions to perform remote procedure calls, the responding entity MUST return a &forbidden; error:</p>
  110. <example caption='Requesting entity is forbidden to perform remote procedure calls'><![CDATA[
  111. <iq type='error'
  112. from='responder@company-a.com/jrpc-server'
  113. to='requester@company-b.com/jrpc-client'
  114. id='rpc1'>
  115. <query xmlns='jabber:iq:rpc'>
  116. <methodCall>
  117. <methodName>examples.getStateName</methodName>
  118. <params>
  119. <param>
  120. <value><i4>6</i4></value>
  121. </param>
  122. </params>
  123. </methodCall>
  124. </query>
  125. <error code='403' type='auth'>
  126. <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  127. </error>
  128. </iq>
  129. ]]></example>
  130. </section1>
  131. <section1 topic='Service Discovery' anchor='disco'>
  132. <p>If an entity supports the Jabber-RPC protocol, it SHOULD advertise that fact in response to &xep0030; information ("diso#info") requests by returning an identity of "automation/rpc" and a feature of "jabber:iq:rpc":</p>
  133. <example caption='A disco#info query'><![CDATA[
  134. <iq type='get'
  135. from='requester@company-b.com/jrpc-client'
  136. to='responder@company-a.com/jrpc-server'
  137. id='disco1'>
  138. <query xmlns='http://jabber.org/protocol/disco#info'/>
  139. </iq>
  140. ]]></example>
  141. <example caption='A disco#info response'><![CDATA[
  142. <iq type='result'
  143. to='requester@company-b.com/jrpc-client'
  144. from='responder@company-a.com/jrpc-server'
  145. id='disco1'>
  146. <query xmlns='http://jabber.org/protocol/disco#info'>
  147. <identity category='automation' type='rpc'/>
  148. <feature var='jabber:iq:rpc'/>
  149. </query>
  150. </iq>
  151. ]]></example>
  152. </section1>
  153. <section1 topic='Security Considerations' anchor='security'>
  154. <p>An entity that supports Jabber-RPC SHOULD establish a "whitelist" of entities that are allowed to perform remote procedure calls and MUST return a &forbidden; error if entities with insufficient permissions attempt such calls.</p>
  155. </section1>
  156. <section1 topic='IANA Considerations' anchor='iana'>
  157. <p>This document requires no interaction with &IANA;.</p>
  158. </section1>
  159. <section1 topic="XMPP Registrar Considerations" anchor='registrar'>
  160. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  161. <p>The &REGISTRAR; includes 'jabber:iq:rpc' in its registry of protocol namespaces.</p>
  162. </section2>
  163. <section2 topic='Service Discovery Identity' anchor='registrar-disco'>
  164. <p>The XMPP Registrar includes a Service Discovery type of "rpc" within the "automation" category in its registry of service discovery identities.</p>
  165. </section2>
  166. </section1>
  167. <section1 topic='XML Schema' anchor='schema'>
  168. <code><![CDATA[
  169. <?xml version='1.0' encoding='UTF-8'?>
  170. <xs:schema
  171. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  172. targetNamespace='jabber:iq:rpc'
  173. xmlns='jabber:iq:rpc'
  174. elementFormDefault='qualified'>
  175. <xs:annotation>
  176. <xs:documentation>
  177. The protocol documented by this schema is defined in
  178. XEP-0009: http://www.xmpp.org/extensions/xep-0009.html
  179. There is no official XML schema for XML-RPC. The main body
  180. of this schema has been borrowed from an unofficial schema
  181. representation contained in the book "Processing XML With
  182. Java" by Elliotte Rusty Harold, as located at:
  183. http://www.ibiblio.org/xml/books/xmljava/chapters/ch02s05.html
  184. </xs:documentation>
  185. </xs:annotation>
  186. <xs:element name='query'>
  187. <xs:complexType>
  188. <xs:choice minOccurs='0' maxOccurs='1'>
  189. <xs:element ref='methodCall'/>
  190. <xs:element ref='methodResponse'/>
  191. </xs:choice>
  192. </xs:complexType>
  193. </xs:element>
  194. <xs:element name="methodCall">
  195. <xs:complexType>
  196. <xs:all>
  197. <xs:element name="methodName">
  198. <xs:simpleType>
  199. <xs:restriction base="ASCIIString">
  200. <xs:pattern value="([A-Za-z0-9]|/|\.|:|_)*" />
  201. </xs:restriction>
  202. </xs:simpleType>
  203. </xs:element>
  204. <xs:element name="params" minOccurs="0" maxOccurs="1">
  205. <xs:complexType>
  206. <xs:sequence>
  207. <xs:element name="param" type="ParamType"
  208. minOccurs="0" maxOccurs="unbounded"/>
  209. </xs:sequence>
  210. </xs:complexType>
  211. </xs:element>
  212. </xs:all>
  213. </xs:complexType>
  214. </xs:element>
  215. <xs:element name="methodResponse">
  216. <xs:complexType>
  217. <xs:choice>
  218. <xs:element name="params">
  219. <xs:complexType>
  220. <xs:sequence>
  221. <xs:element name="param" type="ParamType"/>
  222. </xs:sequence>
  223. </xs:complexType>
  224. </xs:element>
  225. <xs:element name="fault">
  226. <!-- What can appear inside a fault is very restricted -->
  227. <xs:complexType>
  228. <xs:sequence>
  229. <xs:element name="value">
  230. <xs:complexType>
  231. <xs:sequence>
  232. <xs:element name="struct">
  233. <xs:complexType>
  234. <xs:sequence>
  235. <xs:element name="member"
  236. type="MemberType">
  237. </xs:element>
  238. <xs:element name="member"
  239. type="MemberType">
  240. </xs:element>
  241. </xs:sequence>
  242. </xs:complexType>
  243. </xs:element>
  244. </xs:sequence>
  245. </xs:complexType>
  246. </xs:element>
  247. </xs:sequence>
  248. </xs:complexType>
  249. </xs:element>
  250. </xs:choice>
  251. </xs:complexType>
  252. </xs:element>
  253. <xs:complexType name="ParamType">
  254. <xs:sequence>
  255. <xs:element name="value" type="ValueType"/>
  256. </xs:sequence>
  257. </xs:complexType>
  258. <xs:complexType name="ValueType" mixed="true">
  259. <xs:choice>
  260. <xs:element name="i4" type="xs:int"/>
  261. <xs:element name="int" type="xs:int"/>
  262. <xs:element name="string" type="ASCIIString"/>
  263. <xs:element name="double" type="xs:decimal"/>
  264. <xs:element name="base64" type="xs:base64Binary">
  265. <xs:annotation>
  266. <xs:documentation>
  267. Corrected from "Base64" to "base64" in version 2.2 of XEP-0009.
  268. </xs:documentation>
  269. </xs:annotation>
  270. </xs:element>
  271. <xs:element name="boolean" type="NumericBoolean"/>
  272. <xs:element name="dateTime.iso8601" type="xs:dateTime"/>
  273. <xs:element name="array" type="ArrayType"/>
  274. <xs:element name="struct" type="StructType"/>
  275. </xs:choice>
  276. </xs:complexType>
  277. <xs:complexType name="StructType">
  278. <xs:sequence>
  279. <xs:element name="member" type="MemberType"
  280. maxOccurs="unbounded"/>
  281. </xs:sequence>
  282. </xs:complexType>
  283. <xs:complexType name="MemberType">
  284. <xs:sequence>
  285. <xs:element name="name" type="xs:string" />
  286. <xs:element name="value" type="ValueType"/>
  287. </xs:sequence>
  288. </xs:complexType>
  289. <xs:complexType name="ArrayType">
  290. <xs:sequence>
  291. <xs:element name="data">
  292. <xs:complexType>
  293. <xs:sequence>
  294. <xs:element name="value" type="ValueType"
  295. minOccurs="0" maxOccurs="unbounded"/>
  296. </xs:sequence>
  297. </xs:complexType>
  298. </xs:element>
  299. </xs:sequence>
  300. </xs:complexType>
  301. <xs:simpleType name="ASCIIString">
  302. <xs:restriction base="xs:string">
  303. <xs:pattern value="([ -~]|\n|\r|\t)*" />
  304. </xs:restriction>
  305. </xs:simpleType>
  306. <xs:simpleType name="NumericBoolean">
  307. <xs:restriction base="xs:boolean">
  308. <xs:pattern value="0|1" />
  309. </xs:restriction>
  310. </xs:simpleType>
  311. </xs:schema>
  312. ]]></code>
  313. </section1>
  314. </xep>