Possibility to call SOAP from lua?

Hi guys,

I am looking for a way to use SOAP calls from lua. Did anybody try this yet? ???

I can see that there is a SOAP/LUA library here LuaSOAP: SOAP interface to the Lua programming language

… but is this usable straight away in VERA or should it be compiled for vera to work?

If this is a dead-en, could anybody help me finding a way to do SOAP from lua scripting?



Unfortunately there’s some bad news:

[ul][li]LuaSOAP needs LuaExpat[/li]
[li]LuaExpat needs Expat[/li]
[li]Expat is written in C[/li][/ul]

You could compile and deploy the Expat lib directly to Vera, but your code would be harder for others to deploy.

You might want to jump in on this thread, since that would also pull in the libs you need, since a number of different high-level API’s all depend upon this same low level one:


It would enable a LOT of things to be done if it were added.

I haven’t tried it, but as an alternative, you might be able to [tt]os.execute()[/tt] out to [tt]curl[/tt]. You’d end up having to write and read, and delete, a bunch of Temporary files to achieve the same effect as a real API, so I didn’t bother trying it.

anker, you should be able to load the Module now, since CJ’s posting here:


indicates they load [tt]luaexpat[/tt]…

It’s possible to call a soap server with curl from vera2.

Perhaps I could do better but it’s to train me lua code.

here’s the code:

-- SOAP client POST with curl      by Gilles                                      ---

-- a function to excute a shell command
function execute(command)
local file = io.popen (command)
local data = file:read("*a")
if (data == "") then
data = nil
return data

--here you put the request enveloppe for the SOAP server wich call the function getHelloWorld or what else
local req = [[<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.gilles.example.fr/ns"><SOAP-ENV:Body><ns1:getHelloWorld/></SOAP-ENV:Body></SOAP-ENV:Envelope>]]

file_req = io.open("req.lua", "w") -- déclare in a file for using with curl
file_req:write(req) --write in this file your soap enveloppe
local local_url = [[ http://myserver.loc/soap_server/]] --the adress of your soap server
local conc = [[curl -s -X POST -d@]] .. "req.lua" .. local_url -- the concatenation of the curl command

local temp = execute(conc) --the excution of the curl command

print (temp) -- a print check

file_req:close() -- close the file file_req used for soap enveloppe

Thanks to mcvflorin and futzle for their replies.

This should make the code a little simpler, and avoid using OS callouts:
LuaSocket: Network support for the Lua language

Just use [tt]require[/tt] to include lib lib, it’s already installed on Vera.