| 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><a href="manual.html">Manual</a> |
| 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><strong>Examples</strong> |
| 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="examples"></a>Examples</h2> |
| 71 |
|
| 72 |
<a name="soap_elements_example"></a> |
| 73 |
<h3>SOAP elements</h3> |
| 74 |
|
| 75 |
Follows a small example of common XML constructions written in LuaSOAP. |
| 76 |
|
| 77 |
<pre class="example"> |
| 78 |
local simple = { tag = "symbol", "DEF", } --> <symbol>DEF</symbol> |
| 79 |
|
| 80 |
local simple_attr = { |
| 81 |
tag = "symbol", |
| 82 |
anAttribute = "aValue", |
| 83 |
"DEF", |
| 84 |
} --> <symbol anAttribute="aValue">DEF</symbol> |
| 85 |
|
| 86 |
local structured = { |
| 87 |
tag = "PriceAndVolume", |
| 88 |
{ tag = "LastTradePrice", 34.5, }, |
| 89 |
{ tag = "DayVolume", 10000, }, |
| 90 |
} --> <PriceAndVolume><LastTradePrice>34.5</LastTradePrice><DayVolume>10000</DayVolume></PriceAndVolume> |
| 91 |
|
| 92 |
local structured_attr = { |
| 93 |
{ tag = "stooges", |
| 94 |
{ |
| 95 |
tag = "curly", |
| 96 |
attr = { "xsi:type", ["xsi:type"] = "xsd:int", }, |
| 97 |
-21, |
| 98 |
}, |
| 99 |
{ |
| 100 |
tag = "larry", |
| 101 |
attr = { "xsi:type", ["xsi:type"] = "xsd:int", }, |
| 102 |
59, |
| 103 |
}, |
| 104 |
{ |
| 105 |
tag = "moe", |
| 106 |
attr = { "xsi:type", ["xsi:type"] = "xsd:int", }, |
| 107 |
11, |
| 108 |
}, |
| 109 |
}, |
| 110 |
} --> <stooges><curly xsi:type="xsd:int">-21</curly><larry xsi:type="xsd:int">59</larry><moe xsi:type="xsd:int">11</moe></stooges> |
| 111 |
</pre> |
| 112 |
|
| 113 |
<a name="escape_example"></a> |
| 114 |
<h3>Escaping example</h3> |
| 115 |
|
| 116 |
Below is an example of a simple way of escaping strings that contain special characters. Careful must be taken to non-ASCII characters since they have to be converted according to the locale/encoding. |
| 117 |
|
| 118 |
<pre class="example"> |
| 119 |
local escaped_element = { |
| 120 |
tag = "StringEscapingTest", |
| 121 |
{ tag = "string", "<this was automatically escaped", }, |
| 122 |
{ tag = "string", 'do not re-escape my &', }, |
| 123 |
} --> <StringEscapingTest><string>&lt;this was automatically escaped&gt;</string><string>do not re-escape my &amp;</string></StringEscapingTest> |
| 124 |
</pre> |
| 125 |
|
| 126 |
<a name="client_example"></a> |
| 127 |
<h3>Client example</h3> |
| 128 |
|
| 129 |
Below is a small sample code displaying the use of the library in a |
| 130 |
client application. |
| 131 |
Note that the external tag might not be provided in the <code>entries</code> table, since the <code>method</code> field will be used for that purpose. |
| 132 |
|
| 133 |
<pre class="example"> |
| 134 |
local client = require "soap.client" |
| 135 |
local ns, meth, ent = client.call { |
| 136 |
url = "http://soap.4s4c.com/ssss4c/soap.asp", |
| 137 |
soapaction = "doubler", |
| 138 |
method = "http://simon.fell.com/calc", |
| 139 |
entries = { -- `tag' will be filled with `method' field |
| 140 |
{ |
| 141 |
tag = "nums", |
| 142 |
attr = { |
| 143 |
["xmlns:SOAP-ENC"] = "http://schemas.xmlsoap.org/soap/encoding/", |
| 144 |
["SOAP-ENC:arrayType"] = "xsd:int[5]", |
| 145 |
}, |
| 146 |
{ tag = "number", 10 }, |
| 147 |
{ tag = "number", 20 }, |
| 148 |
{ tag = "number", 30 }, |
| 149 |
{ tag = "number", 50 }, |
| 150 |
{ tag = "number", 100 }, |
| 151 |
}, |
| 152 |
} |
| 153 |
} |
| 154 |
print("namespace = ", ns, "element name = ", meth) |
| 155 |
for i, elem in ipairs (ent[1]) do |
| 156 |
print (elem[1]) |
| 157 |
end |
| 158 |
</pre> |
| 159 |
|
| 160 |
</div> <!-- id="content" --> |
| 161 |
|
| 162 |
</div> <!-- id="main" --> |
| 163 |
|
| 164 |
<div id="about"> |
| •165 |
<p><a href="http://validator.w3.org/check?uri=referer">valid</a></p> |
| 166 |
<p><small> |
| 167 |
$Id: examples.html,v 1.2 2009/07/22 19:02:46 tomas Exp $ |
| 168 |
</small></p> |
| 169 |
</div> <!-- id="about" --> |
| 170 |
|
| 171 |
</div> <!-- id="container" --> |
| 172 |
|
| 173 |
</body> |
| 174 |
</html> |