lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I try to use socket.http to send a SOAP message with POST in the body of
http. 
See the following code:

local http = require("socket.http")

    body = [[<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
  <soap:Body>
    <ViewLogStatus
xmlns="http://www.thermo.com/informatics/xmlns/limswebservice"; />
  </soap:Body>
</soap:Envelope>]]

local r,c,h = http.request{
    url = "http://xx/LimsWebService/default.asmx?op=ViewLogStatus";,
    sink = ltn12.sink.file(io.open("test.out", "w")),
    headers = {
      ["Content-Type"] = "text/xml; charset=utf-8",
      ["content-length"] = tostring(body:len()),

["SOAPAction"]="\"http://www.thermo.com/informatics/xmlns/limswebservice/ViewLogStatus\"";
        ["Host"] = "xx",
        },
    body = ltn12.source.string(body),
    method = "POST"
}

This leads always to a timeout and using a wireshark i can see the http
headers only - no body.

I tried a 'trick' to insert the body in the header telegram:

local r,c,h = http.request{
    url = "http://xx/LimsWebService/default.asmx?op=ViewLogStatus";,
    sink = ltn12.sink.file(io.open("test.out", "w")),
    headers = {
        ["Content-Type"] = "text/xml; charset=utf-8",
        ["content-length"] = tostring(body:len()+4),
        ["SOAPAction"] =
"\"http://www.thermo.com/informatics/xmlns/limswebservice/ViewLogStatus
\"",
        ["Host"] = "xx\r\n\r\n\r\n"..body
        },
    method = "POST"
}


This works (more or less) and the server is responding.

Do I misunderstand something with the first (the 'official') version?
Is there a known bug?

Any help is welcome.

Wilhelm