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-0244.xml 41KB

  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>IO Data</title>
  10. <abstract>This specification defines an XMPP protocol extension for handling the input to and output from a remote entity.</abstract>
  12. <number>0244</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XEP-0001</spec>
  20. <spec>XEP-0030</spec>
  21. <spec>XEP-0050</spec>
  22. </dependencies>
  23. <supersedes/>
  24. <supersededby/>
  25. <shortname>NOT_YET_ASSIGNED</shortname>
  26. <author>
  27. <firstname>Johannes</firstname>
  28. <surname>Wagener</surname>
  29. <email></email>
  30. <jid></jid>
  31. </author>
  32. <author>
  33. <firstname>Egon</firstname>
  34. <surname>Willighagen</surname>
  35. <email></email>
  36. <jid></jid>
  37. </author>
  38. <author>
  39. <firstname>Andreas</firstname>
  40. <surname>Heusler</surname>
  41. <email></email>
  42. <jid></jid>
  43. </author>
  44. <author>
  45. <firstname>Tobias</firstname>
  46. <surname>Markmann</surname>
  47. <email></email>
  48. <jid></jid>
  49. </author>
  50. <author>
  51. <firstname>Ola</firstname>
  52. <surname>Spjuth</surname>
  53. <email></email>
  54. <jid></jid>
  55. </author>
  56. <revision>
  57. <version>0.1</version>
  58. <date>2008-06-18</date>
  59. <initials>psa</initials>
  60. <remark><p>Initial published version.</p></remark>
  61. </revision>
  62. <revision>
  63. <version>0.0.4</version>
  64. <date>2008-06-05</date>
  65. <initials>jw/ew</initials>
  66. <remark><p>The IO Data specific commands (procedure status and output request) were moved in the IO Data namespace. The Schema was adapted to become extensible.</p></remark>
  67. </revision>
  68. <revision>
  69. <version>0.0.3</version>
  70. <date>2008-04-16</date>
  71. <initials>jw</initials>
  72. <remark><p>Applied the suggested modifications in result to the discussion on the XMPP standards mailing list.</p></remark>
  73. </revision>
  74. <revision>
  75. <version>0.0.2</version>
  76. <date>2008-03-20</date>
  77. <initials>jw</initials>
  78. <remark><p>Added some missing namespaces in two examples.</p></remark>
  79. </revision>
  80. <revision>
  81. <version>0.0.1</version>
  82. <date>2008-02-25</date>
  83. <initials>jw</initials>
  84. <remark><p>Initial Version.</p></remark>
  85. </revision>
  86. </header>
  87. <section1 topic='Introduction' anchor='intro'>
  88. <section2 topic='About the intention to write this XEP' anchor='intention'>
  89. <p>&xep0050; became a popular and widespread XMPP Protocol Extension to execute functions on a remote systems. It is supported by many XMPP client and service implementations. To date almost all of its implementations rely on &xep0004; to be the data container. However Ad-Hoc Commands is explicitly designed and mentioned to be used in combination with other data containers, too. This applies for the cases where the Data Forms specification does not fit the needs, for example the Data Forms can be too restrictive on strong typing of data (see Section 1.2).</p>
  90. <p>The intention of the present XEP is to define a data container for the cases where Data Forms is not applicable or not optimal. The data container defined herein (IO Data) is very generic and discoverable. It is intended to be used for other purposes than Data Forms.</p>
  91. </section2>
  92. <section2 topic='Limitations of Data Forms' anchor='limits'>
  93. <p>The Data Forms data container has certain restrictive limitations:</p>
  94. <ol>
  95. <li>The supported Field Types are limited: text input fields, drop down boxes, different selectable optional values, etc. See <link url=''>Data Forms - Field Types</link></li>
  96. <li>The only allowed content type of the fields is xs:string. See <link url=''>Data Forms - XML Schema</link></li>
  97. <li>According to current specifications it is not possible to transport complex tree-based data structures. For example nested elements of elements cannot have nested elements at all, therefore lacking an XML key feature.</li>
  98. </ol>
  99. <p>The limitations of Data Forms are not bad. They are good for the special use case a client has to render a graphical representation of the service. In HTML the correlative is a HTML form. For a chat client developer this makes it plain and simple to develop a generic graphical client implementation with some simple text-input fields.</p>
  100. </section2>
  101. <section2 topic='Why an additional data container is required' anchor='sense'>
  102. <p>According to current standards it is not supported to encapsulate more complex data in the Data Forms data container. For example it is not possible to encapsulate a complete XML Document - the real "generic" data container - in the Data Forms data container, unless you encode the XML Document as xs:string – which would be considered bad practice.</p>
  103. <p>However specialized clients are developed to make use of the service oriented architecture of XMPP. An example is given here: a XMPP client implementation reflects an Application Programming Interface (API) with an XMPP services by making use of Ad-Hoc Commands.</p>
  104. <example caption='get_titles.js'><![CDATA[
  105. // javascript syntax
  106. service = client.getService("");
  107. function = service.getFunction("getXmlFile");
  108. // Check if this Ad-Hoc Command supports the IO Data XEP?
  109. if (function instanceof IoDataFunction) {
  110. // Discover the input and output XML Schemata - required only once!
  111. schemata = function.getIoSchemata();
  112. // Dynamically marshal an API for the input and output - required only once!
  113. inputOutputFactory = new IoFactory( schemata );
  114. // Create and set the input
  115. input1 = inputOutputFactory.createInputObject();
  116. input1.setFileName("doc-ID-011021");
  117. // Invoke the function and get the output
  118. result1 = function.invoke(input1);
  119. output1 = inputOutputFactory.getOutputObject(result1);
  120. title1 = output1.getDocumentTitle();
  121. // Next document
  122. input2 = inputOutputFactory.createInputObject();
  123. input2.setFileName("doc-ID-833423");
  124. result2 = function.invoke(input2);
  125. output2 = inputOutputFactory.getOutputObject(result2);
  126. title2 = output1.getDocumentTitle();
  127. ...
  128. }]]></example>
  129. <p>The limitations of Data Forms make it impossible to define and handshake these actions clearly and precisely and without confusing existing and future implementations for the following reasons:</p>
  130. <ol>
  131. <li>Data Forms does not support a "Schemata Discovery". The form descriptor Data Forms provides (type='form') is not separated from the data transaction according to the Ad-Hoc Command logic descibed in XEP-0050. Therefore each function invocation would result in a form descriptor submission again causing unnecessary traffic. It is sufficient to discover the IO Schemata once.</li>
  132. <li>It is not suggested to encapsulate XML Documents in the Data Forms in general.</li>
  133. </ol>
  134. </section2>
  135. <section2 topic='Web Services over XMPP' anchor='ws'>
  136. <p>Beside Ad-Hoc Commands two other XEPs exist that provide mechanisms to execute a function on a remote system. For this count &xep0009; and &xep0072;.</p>
  137. <p>However, Jabber-RPC and SOAP over XMPP lack certain functionality that is important for flexible, simple and robust Web Services. Because of the limited expressiveness of XML-RPCs data types the Jabber-RPC is not suitable for complex functionality, similar to the limitations of Data Forms. While SOAP over XMPP supports complex data types it lacks an obvious mechanism for asynchronous usage. For example it has no default stateful design: there is no sessionid like in Ad-Hoc Commands. Beside this SOAP brings in severe complexity (XML associated abstractions) that was required for the primary transport layer HTTP. This complexity is not required because XMPP does already implement the required XML associated abstractions. In addition to that there are other issues that argument against SOAP. For example to date most HTTP SOAP implemented services are only compatible with a subset of SOAP libraries.</p>
  138. <p>In contrast Ad-Hoc Commands comprises simple, clean and optionally stateful Web Service mechanisms by default. In addition to that asynchronous client notification can be achieved with a &lt;message&gt;, as indicated in Ad-Hoc Commands and as realized in some unofficial implementations.</p>
  139. </section2>
  140. <section2 topic='The IO Data data container' anchor='conclusion'>
  141. <p>In conclusion and as already suggested in Ad-Hoc Commands we describe an alternative data container. This data container is more generic in the way it can be used:</p>
  142. <ol>
  143. <li>It supports a "Schemata Discovery". Thus a client implementation can marshal an API for the input and output (and optionally for a service specific error) of a certain service.</li>
  144. <li>This "Schemata Discovery" is separated from the data transaction. This reduces the amount of unnecessary traffic.</li>
  145. <li>The Field Types of the described data container are on the one hand clearly defined (there is only description, input, output, error, and status) and on the other hand straightforward. Thus any kind of XML data (XML Document with namespaces that represent any imaginable data object) can be submitted.</li>
  146. </ol>
  147. <p>It is important to note that this XEP does not intent to replace or extent Data Forms. Also it does not break any current Ad-Hoc implementations. It just intends to offer another data container that fits much better under some circumstances where no GUI is rendered around an Ad-Hoc Command service.</p>
  148. </section2>
  149. </section1>
  150. <section1 topic='Protocol' anchor='protocol'>
  151. <p>The base syntax for the 'urn:xmpp:tmp:io-data' namespace is as follows &NSNOTE;; a formal description can be found in the XML Schema section below.</p>
  152. <code><![CDATA[
  153. <iodata xmlns='urn:xmpp:tmp:io-data'
  154. type='transaction-type'>
  155. <desc/>
  156. <in/>
  157. <out/>
  158. <error/>
  159. <status>
  160. <elapsed/>
  161. <remaining/>
  162. <percentage/>
  163. <information/>
  164. </status>
  165. </iodata>
  166. ]]></code>
  167. <section2 topic='Transaction Types' anchor='trans'>
  168. <table caption='IO Data Transaction Types allowed for client to service stanzas'>
  169. <tr>
  170. <th>Transaction Type</th>
  171. <th>Purpose</th>
  172. <th>Associated Ad-Hoc Command</th>
  173. <th>REQUIRED for generic XEP compatibility</th>
  174. <th>Contained Elements</th>
  175. </tr>
  176. <tr>
  177. <th>io-schemata-get</th>
  178. <th>To request the schemata of input and output.</th>
  179. <th>execute</th>
  180. <th>yes</th>
  181. <th>-</th>
  182. </tr>
  183. <tr>
  184. <th>input</th>
  185. <th>To submit the input.</th>
  186. <th>execute</th>
  187. <th>yes</th>
  188. <th>&lt;in&gt;</th>
  189. </tr>
  190. <tr>
  191. <th>getStatus</th>
  192. <th>To request the status of the procedure.</th>
  193. <th>next</th>
  194. <th>yes</th>
  195. <th>-</th>
  196. </tr>
  197. <tr>
  198. <th>getOutput</th>
  199. <th>To request the output.</th>
  200. <th>next, complete</th>
  201. <th>yes</th>
  202. <th>-</th>
  203. </tr>
  204. </table>
  205. <table caption='IO Data Transaction Types allowed for service to client stanzas'>
  206. <tr>
  207. <th>Transaction Type</th>
  208. <th>Purpose</th>
  209. <th>Associated Ad-Hoc Command status value</th>
  210. <th>REQUIRED for generic XEP compatibility</th>
  211. <th>Contained Elements</th>
  212. </tr>
  213. <tr>
  214. <th>io-schemata-result</th>
  215. <th>To return the schemata of input and output.</th>
  216. <th>completed</th>
  217. <th>yes</th>
  218. <th>&lt;desc&gt; &lt;in&gt; &lt;out&gt;</th>
  219. </tr>
  220. <tr>
  221. <th>output</th>
  222. <th>To submit the output.</th>
  223. <th>executing, completed</th>
  224. <th>yes</th>
  225. <th>&lt;out&gt;</th>
  226. </tr>
  227. <tr>
  228. <th>error</th>
  229. <th>To submit additional error information.</th>
  230. <th>executing</th>
  231. <th>no</th>
  232. <th>&lt;error&gt;</th>
  233. </tr>
  234. <tr>
  235. <th>status</th>
  236. <th>To indicate the current status of the procedure.</th>
  237. <th>executing</th>
  238. <th>no</th>
  239. <th>&lt;status&gt;</th>
  240. </tr>
  241. </table>
  242. </section2>
  243. <section2 topic='Container Elements' anchor='container'>
  244. <p>&lt;desc&gt; -- a textual description of the IO Data data container (xs:string).</p>
  245. <p>&lt;in&gt; -- contains the input. Valid for Transaction Type 'input' and 'io-schemata-result' only. May contain any XML data (XML Schema, XML Document ...).</p>
  246. <p>&lt;out&gt; -- contains the output. Valid for Transaction Type 'output' and 'io-schemata-result' only. May contain any XML data (XML Schema, XML Document ...).</p>
  247. <p>&lt;error&gt; -- describes the error raised by the procedure invocation. This element is optional and valid for Transaction Type 'error' and 'io-schemata-result' only. May contain any XML data (XML Schema, XML Document ...).</p>
  248. <p>&lt;status&gt; -- describes the status of the procedure. This element is optional and valid for Transaction Type 'status' only.</p>
  249. </section2>
  250. <section2 topic='Status Elements' anchor='status'>
  251. <p>&lt;elapsed&gt; -- an integer value of the time in milliseconds that elapsed since the procedure was invoked (xs:integer).</p>
  252. <p>&lt;remaining&gt; -- an integer value of the (estimated) time in milliseconds till the procedure will finish (xs:integer).</p>
  253. <p>&lt;percentage&gt; -- the percentage of the procedure that is finished (xs:integer).</p>
  254. <p>&lt;information&gt; -- describes the current status of the procedure.</p>
  255. </section2>
  256. </section1>
  257. <section1 topic='Implementation Notes' anchor='impl'>
  258. <p>Commands (= remote procedures) executed with Ad-Hoc Commands and IO Data SHOULD NOT keep the requester in an uncertain state. This means the responder SHOULD respond to the requester always as fast as possible. Thereby the requester acquires the sessionid. (As some remote procedures/calculations are cost-intensive and/or time-consuming the requester MUST "save" this sessionid for the case a network problem occurs.)</p>
  259. <p>The Ad-Hoc Command logic applied for the IO Data data container should be associated with the following rules and keywords:</p>
  260. <table caption='Subsequently allowed Ad-Hoc Commands are depending on the state of the service'>
  261. <tr>
  262. <th>Ad-Hoc Command</th>
  263. <th>Keyword</th>
  264. <th>Associated Transaction Type</th>
  265. <th>Subsequently allowed commands</th>
  266. <th>Status description</th>
  267. </tr>
  268. <tr>
  269. <th>execute</th>
  270. <th>Get Schemata</th>
  271. <th>io-schemata-get</th>
  272. <th>-</th>
  273. <th>XML Schemata are returned immediately</th>
  274. </tr>
  275. <tr>
  276. <th>execute</th>
  277. <th>Start procedure</th>
  278. <th>input</th>
  279. <th>-</th>
  280. <th>output returns immediately (synchronous)</th>
  281. </tr>
  282. <tr>
  283. <th></th>
  284. <th>Start procedure</th>
  285. <th>input</th>
  286. <th>next, cancel</th>
  287. <th>asynchronous procedure was invoked</th>
  288. </tr>
  289. <tr>
  290. <th>next</th>
  291. <th>Check status</th>
  292. <th>getStatus</th>
  293. <th>next, cancel</th>
  294. <th>asynchronous procedure not finished</th>
  295. </tr>
  296. <tr>
  297. <th></th>
  298. <th>Check status</th>
  299. <th>getStatus</th>
  300. <th>next, complete, cancel</th>
  301. <th>asynchronous procedure finished</th>
  302. </tr>
  303. <tr>
  304. <th></th>
  305. <th>Get result</th>
  306. <th>getOutput</th>
  307. <th>next, complete, cancel</th>
  308. <th>result was delivered</th>
  309. </tr>
  310. <tr>
  311. <th>cancel</th>
  312. <th>Cancel/delete procedure</th>
  313. <th>-</th>
  314. <th>-</th>
  315. <th>procedure terminated</th>
  316. </tr>
  317. <tr>
  318. <th>complete</th>
  319. <th>Get result + delete procedure</th>
  320. <th>-</th>
  321. <th>-</th>
  322. <th>result was delivered, procedure terminated</th>
  323. </tr>
  324. </table>
  325. <section2 topic='Synchronous implementation - for immediately completing services' anchor='sync_imp'>
  326. <ol>
  327. <li>If a service can return the output immediately, it MAY respond with status='completed' and return the output (IO Data type='output'). This behavior is NOT RECOMMENDED for procedures that need more than 5 seconds to complete or that are cost-intensive.</li>
  328. </ol>
  329. </section2>
  330. <section2 topic='Asynchronous implementation - for services that cannot return the output immediately' anchor='async_imp'>
  331. <ol>
  332. <li>If a service cannot return the result immediately (this refers to procedures that need more than 5 seconds to complete) or the invoked procedure is cost-intensive, it SHOULD response with status='executing' and a &lt;actions&gt; element containing the &lt;next&gt; element.</li>
  333. <li>If the service returned status='executing' the requester MAY stay up-to-date by proceeding with action='next' combined with the IO Data transaction type='getStatus'. The responder MUST respond with status='executing' and a &lt;actions&gt; element containing the &lt;next&gt; element only as long as the procedure is not finished.</li>
  334. <li>If the procedure finished the responder MUST respond to this request (action='next') combined with the IO Data transaction type='getStatus' with status='executing' and a &lt;actions&gt; element containing the &lt;next&gt; and the &lt;complete&gt; elements to indicate that the output is ready for collection. The requester MAY then request the result by proceeding with action='complete' or action='next' combined with the IO Data transaction type='getOutput'.</li>
  335. <li>Asynchronous notification: If the procedure finished the service MUST actively notify the requester by sending a message containing an Ad-Hoc Command element with status='executing' and a &lt;actions&gt; element containing the &lt;next&gt; and the &lt;complete&gt; elements to indicate that the result is ready for collection.</li>
  336. <li>If the requester requests the output with action='complete' the responder MUST return the result (IO Data transaction type='output') with status='completed'. This means the Ad-Hoc Command session terminated. The responder MUST subsequently delete associated procedure and result.</li>
  337. <li>If the requester requests the output with action='next' combined with the IO Data transaction type='getOutput' the responder MUST return the result (IO Data transaction type='output') with status='executing' and a &lt;actions&gt; element containing the &lt;next&gt; and the &lt;complete&gt; elements to indicate that the the Ad-Hoc Command session continues to exist and the output is still available. The requester MUST subsequently delete the associated procedure and result with action='cancel'.</li>
  338. </ol>
  339. </section2>
  340. <section2 topic='Error handling' anchor='error_imp'>
  341. <p>Beside the errors that are associated with IQ or Ad-Hoc Command abstraction layer an internal procedure error may occur.</p>
  342. <ol>
  343. <li>If the procedure invocation fails (an error occurs) the responder MUST respond with status='completed'. To indicate that the procedure failed the &lt;note&gt; element MUST have type='error' as described in XEP 50 Ad-Hoc Commands. The service may provide additional error information within the IO Data data container (IO Data transaction type='error').</li>
  344. <li>Asynchronous implementation only: If the service returned status='executing' (asynchronous implementation) and the procedure fails (an error occurs) the service MUST actively notify the requester by sending a message containing an Ad-Hoc Command element with status='executing' and a &lt;actions&gt; element containing the &lt;next&gt; element to the invoker. To indicate that the procedure failed the &lt;note&gt; element MUST have type='error' as described in XEP 50 Ad-Hoc Commands. The service may provide additional error information within the IO Data data container (IO Data transaction type='error'). The requester SHOULD subsequently delete the associated procedure with action='cancel'.</li>
  345. <li>Asynchronous implementation only: If the procedure failed (an error occurs) the responder MUST respond to a status request (action='next') with status='executing' and a &lt;actions&gt; element containing the &lt;next&gt; element to the requester. To indicate that the procedure failed the &lt;note&gt; element MUST have type='error' as described in XEP 50 Ad-Hoc Commands. The service may provide additional error information within the IO Data data container (IO Data transaction type='error'). The requester SHOULD subsequently delete the associated procedure with action='cancel'.</li>
  346. </ol>
  347. </section2>
  348. <section2 topic='Optional status information' anchor='status_imp'>
  349. <ol>
  350. <li>As long as the procedure did not finish (!) the service MAY provide additional status information within the IO Data data container (IO Data transaction type='status').</li> </ol>
  351. </section2>
  352. <p>Formalising machine to machine commands using the namespace defined herein, making such commands detectable and usable on-the-fly without the prerequisite for the requester to know the exact interface on the service site and the support for asynchronous as well as synchronous execution contributes to the usability of XMPP for complex grid-computing projects.</p>
  353. <p>In example an IDE could support the development of such projects by generating code interfaces (client stubs) to machine to machine capable XMPP services by discovering and requesting all required information on-the-fly.</p>
  354. </section1>
  355. <section1 topic='Use Cases' anchor='usecases'>
  356. <section2 topic='Discovering support' anchor='ret_coli'>
  357. <p>The requester can query for disco information on the command (Ad-Hoc Command) node to find out if it supports IO Data based commands.</p>
  358. <example caption='Disco request for command information'><![CDATA[
  359. <iq type='get'
  360. from=''
  361. to=''
  362. id='iq_125'>
  363. <query xmlns=''
  364. node='get_threedimensionalcoordinates'/>
  365. </iq>]]></example>
  366. <example caption='Disco result for command information'><![CDATA[
  367. <iq type='result'
  368. from=''
  369. to=''
  370. id='iq_125'>
  371. <query xmlns=''
  372. node='get_threedimensionalcoordinates'>
  373. <feature var=''/>
  374. <feature var='urn:xmpp:tmp:io-data'/>
  375. </query>
  376. </iq>]]></example>
  377. <p>To indicate support for IO Data it MUST include &lt;feature var='urn:xmpp:tmp:io-data'/&gt;. Of course the node can still provide &lt;feature var='jabber:x:data'/&gt; if this is supported, too.</p>
  378. </section2>
  379. <section2 topic='Retrieving the IO Schemata' anchor='ret-schemata'>
  380. <p>The 'in' and 'out' elements may each have any valid XML encoded elements as children. From a XML document style type of view &lt;in/&gt; and &lt;out/&gt; may be seen as root elements. Therefore it is required to "discover" the XML Schemata of the "dynamic children" of &lt;in/&gt; and &lt;out/&gt; (IO Schemata). This way a requester can marshal an API for the input and output of a certain service.</p>
  381. <p>Beside the 'in' and 'out' elements an 'error' element is optionally allowed and would be discovered in exactly the same. It is not included in the example to keep it simple.</p>
  382. <p>The XML Schemata request is done by setting the type of the IO Data element to 'io-schemata-get'.</p>
  383. <example caption='IO Schemata request'><![CDATA[
  384. <iq type='set'
  385. from=''
  386. to=''
  387. id='iq_126'>
  388. <command xmlns=''
  389. node='get_threedimensionalcoordinates'>
  390. <iodata xmlns='urn:xmpp:tmp:io-data' type='io-schemata-get'/>
  391. </command>
  392. </iq>
  393. ]]></example>
  394. <example caption='IO Schemata result'><![CDATA[
  395. <iq type='result'
  396. from=''
  397. to=''
  398. id='iq_126'>
  399. <command xmlns=''
  400. node='get_threedimensionalcoordinates'
  401. status='completed'>
  402. <iodata xmlns='urn:xmpp:tmp:io-data' type='io-schemata-result'>
  403. <desc>
  404. This service returns 3D atomic coordinates for the
  405. input structure. The input and output is encoded using the
  406. Chemical Markup Language (CML).
  407. </desc>
  408. <in>
  409. <xs:complexType>
  410. <xs:any namespace=''
  411. minOccur='1' maxOccur='1'/>
  412. </xs:complexType>
  413. </in>
  414. <out>
  415. <xs:complexType>
  416. <xs:any namespace=''
  417. minOccur='1' maxOccur='1'/>
  418. </xs:complexType>
  419. </out>
  420. </iodata>
  421. </command>
  422. </iq>
  423. ]]></example>
  424. <p>This service example requires the content of &lt;in/&gt; and &lt;out/&gt; to be <cite>Chemical Markup Language</cite> <note>The Chemical Markup Language: &lt;<link url=''></link>&gt;.</note> by requiring input with the namespace ''. Additionally, it also defines the returned output to be <cite>Chemical Markup Language</cite>.</p>
  425. </section2>
  426. <section2 topic='Executing a service' anchor='exec_serv'>
  427. <p>To keep the example simple the children of the 'in' and 'out' elements just contain strings (the protein name and protein sequence). However in real use cases it is likely that the children of 'in' and 'out' contain very complex XML documents with many different valid elements, namespaces, or values.</p>
  428. <p>The requester transmits the input to the service (responder) by setting the type of the IO Data element to 'input'.</p>
  429. <example caption='Execute Command request'><![CDATA[
  430. <iq type='set'
  431. from=''
  432. to=''
  433. id='iq_127'>
  434. <command xmlns=''
  435. node='get_proteinsequence'
  436. action='execute'>
  437. <iodata xmlns='urn:xmpp:tmp:io-data' type='input'>
  438. <in>
  439. <proteinname xmlns=''>
  440. CAB08284
  441. </proteinname>
  442. </in>
  443. </iodata>
  444. </command>
  445. </iq>
  446. ]]></example>
  447. <p>The service transmits the output to the requester by setting the type of the IO Data element to 'output'.</p>
  448. <example caption='Execute command result'><![CDATA[
  449. <iq type='result'
  450. from=''
  451. to=''
  452. id='iq_127'>
  453. <command xmlns=''
  454. sessionid='RPC-SESSION-0000001'
  455. node='get_proteinsequence'
  456. status='completed'>
  457. <iodata xmlns='urn:xmpp:tmp:io-data' type='output'>
  458. <out>
  459. <proteinsequence xmlns=''>
  460. mrkhpqsatk hlfvsggvas slgkgltass lgqlltargl hvtmqkldpy lnvdpgtmnp
  461. fqhgevfvte dgaetdldvg hyerfldrdl sgsanvttgq vystviaker rgeylgdtvq
  462. viphitdeik qrimamaqpd ggdnrpdvvi teiggtvgdi esqpfleaar qvrhdlgren
  463. vfflhvslvp hlapsgelkt kptqhsvaal rsigitpdal ilrcdrdvpe slknkialmc
  464. dvdidgvist pdapsiydip kvlhreelda fvvrrlnlpf rdvdwtewdd llrrvhephg
  465. tvrialvgky vdfsdaylsv sealhaggfk hyakvevvwv asddcetatg aaavladvhg
  466. vlipggfgir giegkigair yararglpvl glclglqciv ieatrsvglv qansaefepa
  467. tpdpvistma dqkeivagea dfggtmrlga ypavlqpasi vaqaygttqv serhrhryev
  468. nnayrdwiae sglrisgtsp dgylvefvey panmhpfvvg tqahpelksr ptrphplfva
  469. fvgaaidyks aellpveipa vpeisehlpn ssnqhrdgve rsfpapaarg
  470. </proteinsequence>
  471. </out>
  472. </iodata>
  473. </command>
  474. </iq>
  475. ]]></example>
  476. </section2>
  477. <section2 topic='Executing a time-consuming service' anchor='exec_serv_time'>
  478. <p>In this example the Ad-Hoc Command is a time-consuming and cost-intensive computation service. To keep the example simple the computation is a WAV to MP3 encoder - the input and output elements of this example make use of &xep0231;.</p>
  479. <example caption='Execute Command request'><![CDATA[
  480. <iq type='set'
  481. from=''
  482. to=''
  483. id='iq_128'>
  484. <command xmlns=''
  485. node='wav2mp3'
  486. action='execute'>
  487. <iodata xmlns='urn:xmpp:tmp:io-data' type='input'>
  488. <in>
  489. <data xmlns='urn:xmpp:tmp:data-element'
  490. alt='my-song.wav'
  491. type='audio/x-wav'>
  492. [ ... base64-encoded-audio ... ]
  493. </data>
  494. </in>
  495. </iodata>
  496. </command>
  497. </iq>
  498. ]]></example>
  499. <p>The service notifies the requester that the job is accepted: status='executing' and a &lt;actions&gt; element contains the &lt;next&gt; element.</p>
  500. <example caption='Execute command result'><![CDATA[
  501. <iq type='result'
  502. from=''
  503. to=''
  504. id='iq_128'>
  505. <command xmlns=''
  506. sessionid='RPC-SESSION-0000002'
  507. node='wav2mp3'
  508. status='executing'>
  509. <note type='info'>WAV to MP3 encoding has been started. You may stay up to
  510. date using the next-action.
  511. </note>
  512. <actions>
  513. <next/>
  514. </actions>
  515. </command>
  516. </iq>
  517. ]]></example>
  518. <p>The requester MAY stay up-to-date by proceeding with action='next' combined with the IO Data transaction type='getStatus'.</p>
  519. <example caption='Execute Command request'><![CDATA[
  520. <iq type='set'
  521. from=''
  522. to=''
  523. id='iq_129a'>
  524. <command xmlns=''
  525. sessionid='RPC-SESSION-0000002'
  526. node='wav2mp3'
  527. action='next'>
  528. <iodata xmlns='urn:xmpp:tmp:io-data' type='getStatus'>
  529. </command>
  530. </iq>
  531. ]]></example>
  532. <p>The service returns the status of the procedure. The "still calculating"-status is indicated with the &lt;actions&gt; element that contains the &lt;next&gt; element only. The "calculation finished"-status is indicated with the &lt;actions&gt; element that contains the &lt;next&gt; and &lt;complete&gt; elements.</p>
  533. <p>Optionally the result MAY contain additional status information within the IO Data element with IO Data transaction type='status' although is not shown here to keep the example simple.</p>
  534. <example caption='Execute command result'><![CDATA[
  535. <iq type='result'
  536. from=''
  537. to=''
  538. id='iq_129a'>
  539. <command xmlns=''
  540. sessionid='RPC-SESSION-0000002'
  541. node='wav2mp3'
  542. status='executing'>
  543. <actions>
  544. <next/>
  545. </actions>
  546. </command>
  547. </iq>
  548. ]]></example>
  549. <p>If the procedure is complete the service notifies the invoker with a message stanza containing an Ad-Hoc Command namespace with status='executing' and a &lt;actions&gt; element that contains the &lt;next&gt; and &lt;complete&gt; elements. The &lt;complete&gt; element indicates the calculation finished.</p>
  550. <example caption='Notification message'><![CDATA[
  551. <message from=''
  552. to=''>
  553. <command xmlns=''
  554. sessionid='RPC-SESSION-0000002'
  555. node='wav2mp3'
  556. status='executing'>
  557. <note type='info'>WAV to MP3 encoding finished. You may request the
  558. output now.</note>
  559. <actions>
  560. <complete/>
  561. <next/>
  562. </actions>
  563. </command>
  564. </iq>
  565. ]]></example>
  566. <p>After that the requester can request the output with the Ad-Hoc Command action='complete'.</p>
  567. <example caption='Execute Command request'><![CDATA[
  568. <iq type='set'
  569. from=''
  570. to=''
  571. id='iq_130a'>
  572. <command xmlns=''
  573. sessionid='RPC-SESSION-0000002'
  574. node='wav2mp3'
  575. action='complete'/>
  576. </iq>
  577. ]]></example>
  578. <p>The service returns the MP3 within the IO Data element. The status of the Ad-Hoc Command completed (status='completed').</p>
  579. <example caption='Execute command result'><![CDATA[
  580. <iq type='result'
  581. from=''
  582. to=''
  583. id='iq_130a'>
  584. <command xmlns=''
  585. sessionid='RPC-SESSION-0000002'
  586. node='wav2mp3'
  587. status='completed'>
  588. <iodata xmlns='urn:xmpp:tmp:io-data' type='output'>
  589. <out>
  590. <data xmlns='urn:xmpp:tmp:data-element'
  591. alt='my-song.mp3'
  592. type='audio/mpeg'>
  593. [ ... base64-encoded-audio ... ]
  594. </data>
  595. </out>
  596. </iodata>
  597. </command>
  598. </iq>
  599. ]]></example>
  600. <p>Alternatively the requester can request the output with the Ad-Hoc Command action='next' combined with the IO Data transaction type='getOutput'. This will keep the Ad-Hoc Command session alive and it must be deleted subsequently. This design allows to recover from network breakage during the result transmission state of the client-server communication, but allowing to request receiving the computation results or second time, because the session was left open after the first request.</p>
  601. <example caption='Execute Command request'><![CDATA[
  602. <iq type='set'
  603. from=''
  604. to=''
  605. id='iq_130b'>
  606. <command xmlns=''
  607. sessionid='RPC-SESSION-0000002'
  608. node='wav2mp3'
  609. action='next'>
  610. <iodata xmlns='urn:xmpp:tmp:io-data' type='getOutput'>
  611. </command>
  612. </iq>
  613. ]]></example>
  614. <p>The service returns the MP3 within the IO Data element. The status of the Ad-Hoc Command remains active (status='executing').</p>
  615. <example caption='Execute command result'><![CDATA[
  616. <iq type='result'
  617. from=''
  618. to=''
  619. id='iq_130b'>
  620. <command xmlns=''
  621. sessionid='RPC-SESSION-0000002'
  622. node='wav2mp3'
  623. status='executing'>
  624. <actions>
  625. <complete/>
  626. <next/>
  627. </actions>
  628. <iodata xmlns='urn:xmpp:tmp:io-data' type='output'>
  629. <out>
  630. <data xmlns='urn:xmpp:tmp:data-element'
  631. alt='my-song.mp3'
  632. type='audio/mpeg'>
  633. [ ... base64-encoded-audio ... ]
  634. </data>
  635. </out>
  636. </iodata>
  637. </command>
  638. </iq>
  639. ]]></example>
  640. <p>The requester MUST subsequently delete the remote procedure with the Ad-Hoc Command action='cancel'.</p>
  641. <example caption='Execute Command request'><![CDATA[
  642. <iq type='set'
  643. from=''
  644. to=''
  645. id='iq_131'>
  646. <command xmlns=''
  647. sessionid='RPC-SESSION-0000002'
  648. node='wav2mp3'
  649. action='cancel'/>
  650. </iq>
  651. ]]></example>
  652. <p>The remote procedure is deleted.</p>
  653. <example caption='Execute command result'><![CDATA[
  654. <iq type='result'
  655. from=''
  656. to=''
  657. id='iq_130'>
  658. <command xmlns=''
  659. sessionid='RPC-SESSION-0000002'
  660. node='wav2mp3'
  661. status='canceled'/>
  662. </iq>
  663. ]]></example>
  664. </section2>
  665. <section2 topic='Asynchronous error notification' anchor='async_error_serv_time'>
  666. <p>In case of an error the service the service notifies the invoker with a message stanza containing an Ad-Hoc Command namespace with status='executing' and a &lt;actions&gt; element that contains the &lt;next&gt; element. In addition to that it MUST contain a &lt;note&gt; element with type='error' to indicate the error.</p>
  667. <p>The error notification MAY contain additional error information within the IO Data element with IO Data transaction type='error'.</p>
  668. <example caption='Error notification message'><![CDATA[
  669. <message from=''
  670. to=''>
  671. <command xmlns=''
  672. sessionid='RPC-SESSION-0000002'
  673. node='wav2mp3'
  674. status='executing'>
  675. <note type='error'>#593 - The encoder could not parse the file.</note>
  676. <actions>
  677. <next/>
  678. </actions>
  679. <iodata xmlns='urn:xmpp:tmp:io-data' type='error'>
  680. <error>
  681. <errorcode/>593</errorcode>
  682. <description>The encoder could not parse the file.</description>
  683. </error>
  684. </iodata>
  685. </command>
  686. </iq>
  687. ]]></example>
  688. <p>In case of an error the service would respond to a status request (Ad-Hoc Command action='next' combined with the IO Data transaction type='getStatus') in a very similar way except that a &lt;iq&gt; and not a &lt;message&gt; would be used.</p>
  689. </section2>
  690. <section2 topic='Canceling a time-consuming service' anchor='cancel_serv_time'>
  691. <p>An asynchronous remote procedure may be canceled (deleted) by the invoker at any time.</p>
  692. <example caption='Cancel Command request'><![CDATA[
  693. <iq type='set'
  694. from=''
  695. to=''
  696. id='iq_129b'>
  697. <command xmlns=''
  698. node='wav2mp3'
  699. action='cancel'/>
  700. </iq>
  701. ]]></example>
  702. <p>The remote procedure is deleted.</p>
  703. <example caption='Cancel command result'><![CDATA[
  704. <iq type='result'
  705. from=''
  706. to=''
  707. id='iq_129b'>
  708. <command xmlns=''
  709. sessionid='RPC-SESSION-0000002'
  710. node='wav2mp3'
  711. status='canceled'/>
  712. </iq>
  713. ]]></example>
  714. </section2>
  715. </section1>
  716. <section1 topic='Error Codes' anchor='error'>
  717. <p>Error codes on the Ad-Hoc Command abstraction layer are inherited from Ad-Hoc Commands.</p>
  718. <p>Application specific errors associated with a remote procedure call realized with IO Data in combination with Ad-Hoc Commands were described in section 3 - Implementation notes.</p>
  719. </section1>
  720. <section1 topic='Internationalization Considerations' anchor='i18n'>
  721. <p>Internationalization of messages sent by the server is covered by setting the @xml:lang attribute of the &lt;iq&gt; element. Services should reply in the same language in which the client asked the question. That is, if the client specifies a locale using the @xml:lang attribute on the &lt;iq> element, then the server should reply in the same locale, and localize messages given in &lt;desc&gt;, &lt;node&gt;@info and &lt;query&gt;&lt;item&gt;@name.</p>
  722. </section1>
  723. <section1 topic='Security Considerations' anchor='security'>
  724. <p>To follow.</p>
  725. </section1>
  726. <section1 topic='IANA Considerations' anchor='iana'>
  727. <p>This document requires no interaction with &IANA;.</p>
  728. </section1>
  729. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  730. <section2 topic='Protocol Namespaces' anchor='ns'>
  731. <p>Until this specification advances to a status of Draft, its associated namespace shall be "urn:xmpp:tmp:io-data"; upon advancement of this specification, the &REGISTRAR; shall issue a permanent namespace in accordance with the process defined in Section 4 of &xep0053;.</p>
  732. </section2>
  733. </section1>
  734. <section1 topic='XML Schema' anchor='schema'>
  735. <code><![CDATA[
  736. <?xml version='1.0' encoding='UTF-8'?>
  737. <xs:schema
  738. xmlns:xs=''
  739. targetNamespace='urn:xmpp:tmp:io-data'
  740. xmlns='urn:xmpp:tmp:io-data'
  741. elementFormDefault='qualified'>
  742. <xs:element name='iodata'>
  743. <xs:complexType>
  744. <xs:element name='desc' minOccurs='0' maxOccurs='1'
  745. type='xs:string'/>
  746. <xs:element name='in' minOccurs='0' maxOccurs='1'/>
  747. <xs:element name='out' minOccurs='0' maxOccurs='1'/>
  748. <xs:element name='error' minOccurs='0' maxOccurs='1'/>
  749. <xs:element name='status' minOccurs='0' maxOccurs='1'/>
  750. <xs:attribute name='type' use='required'>
  751. <xs:simpleType>
  752. <xs:restriction base='xs:NCName'>
  753. <xs:enumeration value='io-schemata-get'/>
  754. <xs:enumeration value='io-schemata-result'/>
  755. <xs:enumeration value='input'/>
  756. <xs:enumeration value='output'/>
  757. <xs:enumeration value='getStatus'/>
  758. <xs:enumeration value='getOutput'/>
  759. <xs:enumeration value='error'/>
  760. <xs:enumeration value='status'/>
  761. </xs:restriction>
  762. </xs:simpleType>
  763. </xs:attribute>
  764. <xs:anyAttribute/>
  765. </xs:complexType>
  766. </xs:element>
  767. <xs:element name='in'>
  768. <xs:choice>
  769. <!-- for x@type='io-schemata-result' : -->
  770. <xs:any namespace=''
  771. minOccurrence='1' maxOccurence='1'/>
  772. <!-- for x@type='input' : -->
  773. <xs:any namespace='##other' processContents='strict'/>
  774. </xs:choice>
  775. </xs:element>
  776. <xs:element name='out'>
  777. <xs:choice>
  778. <!-- for x@type='io-schemata-result' : -->
  779. <xs:any namespace=''
  780. minOccurrence='1' maxOccurence='1'/>
  781. <!-- for x@type='output' : -->
  782. <xs:any namespace='##other' processContents='strict'/>
  783. </xs:choice>
  784. </xs:element>
  785. <xs:element name='error'>
  786. <xs:choice>
  787. <!-- for x@type='io-schemata-result' : -->
  788. <xs:any namespace=''
  789. minOccurrence='1' maxOccurence='1'/>
  790. <!-- for x@type='error' : -->
  791. <xs:any namespace='##other' processContents='strict'/>
  792. </xs:choice>
  793. </xs:element>
  794. <xs:element name='status'>
  795. <!-- for x@type='status' -->
  796. <xs:element name='elapsed' minOccurs='0' maxOccurs='1'
  797. type='xs:integer'/>
  798. <xs:element name='remaining' minOccurs='0' maxOccurs='1'
  799. type='xs:integer'/>
  800. <xs:element name='percentage' minOccurs='0' maxOccurs='1'
  801. type='xs:integer'/>
  802. <xs:element name='information' minOccurs='0' maxOccurs='1'
  803. type='xs:string'/>
  804. </xs:element>
  805. </xs:schema>
  806. ]]></code>
  807. </section1>
  808. <section1 topic='Acknowledgements' anchor='ackn'>
  809. <p><link url=''>The Bioclipse Project</link></p>
  810. </section1>
  811. </xep>