21.04.2020, 10:56
Try this example, change host and parameters inside body variable as needed. Keep in mind that for other services like users you need to change service variable according to the documentation.
Code:
function soaprequest(host, service, body)
local ltn12 = require('ltn12')
local https = require('ssl.https')
local sink = {}
local res, err = https.request({
url = 'https://' .. host .. ':8181/ServerPlatform/' .. service,
method = 'POST',
headers = {
['Content-Length'] = #body,
},
sink = ltn12.sink.table(sink),
source = ltn12.source.string(body),
})
if res then
return table.concat(sink)
else
return nil, err
end
end
host = '192.168.1.1'
service = 'DoorsWebService'
body = [[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.ws.ts1000.tesa.es/">
<soapenv:Header/>
<soapenv:Body>
<soap:doorClose>
<operatorName>operator1</operatorName>
<operatorPassword>myPassword1</operatorPassword>
<doorName>door1</doorName>
</soap:doorClose>
</soapenv:Body>
</soapenv:Envelope>]]
res, err = soaprequest(host, service, body)
log(res, err)