1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>LuaSOAP: SOAP interface to the Lua programming language</title>
<link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"><a href="http://www.keplerproject.org">
<img alt="LuaSOAP logo" src="luasoap.png"/>
</a></div>
<div id="product_name"><big><b>LuaSOAP</b></big></div>
<div id="product_description">SOAP interface for the Lua programming language</div>
</div> <!-- id="product" -->
<div id="main">
<div id="navigation">
<h1>LuaSOAP</h1>
<ul>
<li><a href="index.html">Home</a>
<ul>
<li><a href="index.html#overview">Overview</a></li>
<li><a href="index.html#status">Status</a></li>
<li><a href="index.html#download">Download</a></li>
<li><a href="index.html#history">History</a></li>
<li><a href="index.html#credits">Credits</a></li>
<li><a href="index.html#contact">Contact us</a></li>
</ul>
</li>
<li><a href="manual.html">Manual</a>
<ul>
<li><a href="manual.html#introduction">Introduction</a></li>
<li><a href="manual.html#installation">Installation</a></li>
<li><a href="manual.html#soap_elements">LuaSOAP elements</a></li>
<li><a href="manual.html#basic">Basic support</a>
<ul>
<li><a href="manual.html#encode">encode</a></li>
<li><a href="manual.html#decode">decode</a></li>
</ul>
</li>
<li><a href="manual.html#client">Client side</a>
<ul>
<li><a href="manual.html#call">call</a></li>
<li><a href="manual.html#https">HTTPS and ...</a></li>
</ul>
</li>
<li><a href="manual.html#references">References</a></li>
</ul>
</li>
<li><strong>Examples</strong>
<ul>
<li><a href="#soap_elements_example">SOAP elements</a></li>
<li><a href="#escape_example">Escaping example</a></li>
<li><a href="#client_example">Client example</a></li>
</ul>
</li>
<li><a href="license.html">License</a></li>
</ul>
</div> <!-- id="navigation" -->
<div id="content">
<h2><a name="examples"></a>Examples</h2>
<a name="soap_elements_example"></a>
<h3>SOAP elements</h3>
Follows a small example of common XML constructions written in LuaSOAP.
<pre class="example">
local simple = { tag = "symbol", "DEF", } --> <symbol>DEF</symbol>
local simple_attr = {
tag = "symbol",
anAttribute = "aValue",
"DEF",
} --> <symbol anAttribute="aValue">DEF</symbol>
local structured = {
tag = "PriceAndVolume",
{ tag = "LastTradePrice", 34.5, },
{ tag = "DayVolume", 10000, },
} --> <PriceAndVolume><LastTradePrice>34.5</LastTradePrice><DayVolume>10000</DayVolume></PriceAndVolume>
local structured_attr = {
{ tag = "stooges",
{
tag = "curly",
attr = { "xsi:type", ["xsi:type"] = "xsd:int", },
-21,
},
{
tag = "larry",
attr = { "xsi:type", ["xsi:type"] = "xsd:int", },
59,
},
{
tag = "moe",
attr = { "xsi:type", ["xsi:type"] = "xsd:int", },
11,
},
},
} --> <stooges><curly xsi:type="xsd:int">-21</curly><larry xsi:type="xsd:int">59</larry><moe xsi:type="xsd:int">11</moe></stooges>
</pre>
<a name="escape_example"></a>
<h3>Escaping example</h3>
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.
<pre class="example">
local escaped_element = {
tag = "StringEscapingTest",
{ tag = "string", "<this was automatically escaped", },
{ tag = "string", 'do not re-escape my &', },
} --> <StringEscapingTest><string>&lt;this was automatically escaped&gt;</string><string>do not re-escape my &amp;</string></StringEscapingTest>
</pre>
<a name="client_example"></a>
<h3>Client example</h3>
Below is a small sample code displaying the use of the library in a
client application.
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.
<pre class="example">
local client = require "soap.client"
local ns, meth, ent = client.call {
url = "http://soap.4s4c.com/ssss4c/soap.asp",
soapaction = "doubler",
method = "http://simon.fell.com/calc",
entries = { -- `tag' will be filled with `method' field
{
tag = "nums",
attr = {
["xmlns:SOAP-ENC"] = "http://schemas.xmlsoap.org/soap/encoding/",
["SOAP-ENC:arrayType"] = "xsd:int[5]",
},
{ tag = "number", 10 },
{ tag = "number", 20 },
{ tag = "number", 30 },
{ tag = "number", 50 },
{ tag = "number", 100 },
},
}
}
print("namespace = ", ns, "element name = ", meth)
for i, elem in ipairs (ent[1]) do
print (elem[1])
end
</pre>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<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>
<p><small>
$Id: examples.html,v 1.2 2009/07/22 19:02:46 tomas Exp $
</small></p>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
|