Debian Codegraph @

doc/us/manual.html

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>LuaSOAP: SOAP interface to the Lua programming language</title>
6 <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
8 </head>
9 <body>
10
11 <div id="container">
12
13 <div id="product">
14 <div id="product_logo"><a href="http://www.keplerproject.org">
15 <img alt="LuaSOAP logo" src="luasoap.png"/>
16 </a></div>
17 <div id="product_name"><big><b>LuaSOAP</b></big></div>
18 <div id="product_description">SOAP interface for the Lua programming language</div>
19 </div> <!-- id="product" -->
20
21 <div id="main">
22
23 <div id="navigation">
24 <h1>LuaSOAP</h1>
25 <ul>
26 <li><a href="index.html">Home</a>
27 <ul>
28 <li><a href="index.html#overview">Overview</a></li>
29 <li><a href="index.html#status">Status</a></li>
30 <li><a href="index.html#download">Download</a></li>
31 <li><a href="index.html#history">History</a></li>
32 <li><a href="index.html#credits">Credits</a></li>
33 <li><a href="index.html#contact">Contact us</a></li>
34 </ul>
35 </li>
36 <li><strong>Manual</strong>
37 <ul>
38 <li><a href="manual.html#introduction">Introduction</a></li>
39 <li><a href="manual.html#installation">Installation</a></li>
40 <li><a href="manual.html#soap_elements">LuaSOAP elements</a></li>
41 <li><a href="manual.html#basic">Basic support</a>
42 <ul>
43 <li><a href="manual.html#encode">encode</a></li>
44 <li><a href="manual.html#decode">decode</a></li>
45 </ul>
46 </li>
47 <li><a href="manual.html#client">Client side</a>
48 <ul>
49 <li><a href="manual.html#call">call</a></li>
50 <li><a href="manual.html#https">HTTPS and ...</a></li>
51 </ul>
52 </li>
53 <li><a href="manual.html#references">References</a></li>
54 </ul>
55 </li>
56 <li><a href="examples.html">Examples</a>
57 <ul>
58 <li><a href="#soap_elements_example">SOAP elements</a></li>
59 <li><a href="#escape_example">Escaping example</a></li>
60 <li><a href="#client_example">Client example</a></li>
61 </ul>
62 </li>
63 <li><a href="license.html">License</a></li>
64 </ul>
65 </div> <!-- id="navigation" -->
66
67 <div id="content">
68
69
70 <h2><a name="introduction"></a>Introduction</h2>
71
72 <p>LuaSOAP is a <a href="http://www.lua.org">Lua</a> library to ease the use
73 of <a href="http://www.w3.org/TR/2003/REC-soap12-part0-20030624/">SOAP</a>.
74 It enables a Lua program to:</p>
75
76 <ul>
77 <li>Encode and decode SOAP messages without having to deal directly
78 with XML code </li>
79 <li>Invoke remote Web Services without having to deal directly with
80 SOAP messages </li>
81 </ul>
82
83 <p>LuaSOAP provides a very simple API and an abstraction layer over
84 XML avoiding manipulation of string representation of data
85 structures.</p>
86
87 <p>LuaSOAP is based on
88 <a href="http://matthewwild.co.uk/projects/luaexpat/">LuaExpat</a> and on
89 <a href="http://www.lua.org">Lua 5.1</a>.
90 The abstraction layer over HTTP depends on
91 <a href="http://w3.impa.br/~diego/software/luasocket/">LuaSocket 2.0</a>.
92 An optional layer over HTTPS depends on
93 <a href="http://www.inf.puc-rio.br/~brunoos/luasec/">LuaSec 0.4</a>.
94 </p>
95
96 <h2><a name="installation"></a>Installation</h2>
97
98 <p>LuaSOAP is a Lua library composed by a main module (<code>soap.lua</code>)
99 and some extensions: <code>client.lua</code> and <code>server.lua</code>.
100 The main module must be copied to your <code>package.path</code> and the
101 other two files to a <code>soap</code> directory in your
102 <code>package.path</code>.
103
104 <p>LuaSOAP can also be installed via <a href="http://luarocks.org">LuaRocks</a>
105 with the command <code>luarocks install luasoap</code>.
106 You can check the available rocks at <a href="http://luarocks.org/repositories/rocks/">LuaRocks' main repository</a>.</p>
107
108
109 <h2><a name="soap_elements"></a>LuaSOAP elements</h2>
110
111 <p>LuaSOAP elements are always represented by Lua tables except
112 strings. A LuaSOAP element is a table of the form defined by the <a
113 href="http://matthewwild.co.uk/projects/luaexpat/lom.html">Lua Object
114 Model</a> from the <a href=
115 "http://matthewwild.co.uk/projects/luaexpat/">LuaExpat</a> library. The
116 table has the following characteristics:</p>
117
118 <ul>
119 <li>a special field called <code>tag</code> with the element's
120 name;</li>
121
122 <li>a special optional field called <code>attr</code> with the
123 element's attributes (see next section);</li>
124
125 <li>the element's children are stored at the <em>array-part</em> of
126 the table. A child could be an ordinary string or a LuaSOAP element (a
127 Lua table following these same rules).</li>
128 </ul>
129
130 <h4>Attributes</h4>
131
132 <p>The special field <code>attr</code> is a Lua table that stores
133 the LuaSOAP element's attributes as pairs
134 <em>&lt;key&gt;=&lt;value&gt;</em>. To assure an order (if
135 necessary), the sequence of <em>key</em>s should be placed at the
136 <em>array-part</em> of that table.</p>
137
138 <p>This documentation provides a
139 <a href="examples.html#soap_elements_example">detailed example</a>
140 which shows some common use cases.</p>
141
142 <a name="escaping"></a>
143 <h4>Escaping and special characters</h4>
144
145 <p>
146 Since LuaSOAP 3.0, the library took the responsibility to escape data
147 inside LuaSOAP elements (<code>entries</code> field of soap envelope; see
148 function <a href="#encode">soap.encode</a> below).
149 Therefore, XML special characters such as <code>&lt;</code> and
150 <code>&gt;</code> are automatically converted to the corresponding XML
151 entities (<code>&amp;lt;</code> and <code>&amp;gt;</code>, respectively).
152 </p>
153
154 <p>This documentation provides <a href="examples.html#escape_example">examples</a>
155 which show some common use cases.</p>
156
157 <h2><a name="basic"></a>Basic support</h2>
158
159 <p>The module <code>soap</code> implements all basic support for
160 encoding and decoding SOAP messages. There are two functions:</p>
161
162 <ul>
163 <a name="encode"></a>
164 <li><b><code>encode(args) =&gt; envelope</code></b><br/>
165 Builds a SOAP document containing a <code>SOAP-Envelope</code> element.
166 It receives a table with the following fields:
167 <ul>
168 <li><b><code>namespace</code></b> a string with an URI indicating the namespace (<code>xmlns</code>) atribute of the request,</li>
169 <li><b><code>method</code></b> a string with the method's name,</li>
170 <li><b><code>entries</code></b> an array (a table with numeric keys) of <a href="#soap_elements">LuaSOAP elements</a>,</li>
171 <li><b><code>header</code></b> (<em>optional</em>) a table of headers (<code>soap:Header</code> element; a <a href="#soap_elements">LuaSOAP element</a> too),</li>
172 <li><b><code>soapversion</code></b> (<em>optional</em>; default = 1.1) a number with the SOAP version (currently supported versions are 1.1 and 1.2),</li>
173 <li><b><code>internal_namespace</code></b> (<em>optional</em>; default = "") a string with the `internal' namespace (<code>xmlns:<em>internal_namespace</em></code>)</li>
174 </ul>
175 The result is always a string containing the SOAP document.<br/>
176 The function can raise errors in case the <code>args</code> table is
177 mal formed.
178 </li>
179
180 <a name="decode"></a>
181 <li><b><code>decode (method_response) =&gt; namespace,
182 method_name, elements</code></b><br/>
183 Disassembles a SOAP document into Lua objects.
184 It receives a string containing the SOAP document.
185 The results are: the namespace (string),
186 the SOAP-element method's name (string) and
187 a table with the contents of the SOAP Body.
188 Each element of the <code>elements</code> table can be a
189 string or a <a href="#soap_elements">LuaSOAP element</a>.
190 </li>
191 </ul>
192
193
194 <h2><a name="client"></a>Client side</h2>
195
196 <p>The module <code>soap.client</code> implements a stand-alone client
197 which works over HTTP and is based on <a href=
198 "http://w3.impa.br/~diego/software/luasocket/">LuaSocket 2.0</a>.
199 The following function is provided:</p>
200
201 <ul>
202 <li style="list-style: none"><a name="call"></a></li>
203
204 <li><b><code>call (args) =&gt; namespace, method_name, elements</code></b><br/>
205 It encapsulates the call of <code>encode</code> and <code>decode</code>
206 over a connection to an HTTP server, thus the arguments are passed to the
207 <code>encode</code> function and the results received from the
208 <code>decode</code> function.
209 It receives a table with the following fields:
210 <ul>
211 <li><b><code>url</code></b> a string with the URL of the service (the protocol should be <code>http</code> or <code>https</code>, which requires the load of <a href="http://www.inf.puc-rio.br/~brunoos/luasec/">LuaSec</a>'s <code>ssl.https</code> module),</li>
212 <li><b><code>soapaction</code></b> a string with the value of the <code>SOAPAction</code> header,</li>
213 <li><b><code>encoding</code></b> (<em>optional</em>; default = "") a string with the text encoding (usually <code>"utf-8"</code> or <code>"iso-8859-1"</code>),</li>
214 <li><em>other arguments to the <code><a href="#encode">encode</a></code> function</em></li>
215 </ul>
216 The results are the same as the <code><a href="#decode">decode</a></code>
217 function: the namespace (string), the SOAP-element method's name (string) and
218 a table with the contents of the SOAP Body.</li>
219 </ul>
220
221 <h4><a name="https"></a>HTTPS and SOAP over other transport layers</h4>
222
223 <p>
224 LuaSOAP client module was designed to work over HTTP (via LuaSocket's
225 <code>socket.http</code> module) and HTTPS (via LuaSec's
226 <code>ssl.https</code> module).
227 In fact, it could be used over other protocols since they provide
228 LuaSocket's <code>socket.http.request</code> function.
229 </p>
230 <p>
231 The <code>soap.client.call</code> function inspects the URL to check
232 what protocol the SOAP message is supposed to be transfered upon.
233 Then, it looks for a function called <code>request</code> at the
234 <code>soap.client.<i>protocol</i></code> (where <i>protocol</i> is a
235 table which has an entry called <code>request</code> which is a
236 function with the same signature of
237 <a href="http://w3.impa.br/~diego/software/luasocket/http.html#request">LuaSocket's <code>socket.http.request</code></a>.
238 Thus, the support fot HTTPS can be enabled by a program with the following lines:
239 <pre class="example">
240 local soap_client = require"soap.client"
241 soap_client.https = require"ssl.https"
242 </pre>
243 <p>
244 By following this approach, one could extend LuaSOAP to use another protocol
245 by implementing a function equivalent to LuaSocket's <code>socket.http.request</code>
246 or LuaSec's <code>ssl.https.request</code>.</p>
247
248
249 <h2><a name="references"></a>References</h2>
250
251 Here is a list of related documentation:
252
253 <ul>
254 <li><a href=
255 "http://www.w3.org/XML/">http://www.w3.org/XML/</a></li>
256 </ul>
257
258 </div> <!-- id="content" -->
259
260 </div> <!-- id="main" -->
261
262 <div id="about">
263 <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
264 <p><small>
265 $Id: manual.html,v 1.10 2009/08/10 19:04:40 tomas Exp $
266 </small></p>
267 </div> <!-- id="about" -->
268
269 </div> <!-- id="container" -->
270
271 </body>
272 </html>