Lua
Lua
SOAP Request to fseservicetest.sanita.finanze.it with Smart Card Authentication (TS-CNS Italian Card)
See more HTTP Misc Examples
Demonstrates sending a SOAP request to fseservicetest.sanita.finanze.it with Smart Card (TS-CNS Italian Card).Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
local xml = chilkat.Xml.new()
local success = false
-- --------------------------------------------------------------------------------
-- Also see Chilkat's Online WSDL Code Generator
-- to generate code and SOAP Request and Response XML for each operation in a WSDL.
-- --------------------------------------------------------------------------------
-- Create the SOAP envelope...
xml.tag = "soapenv:Envelope"
xml:add_attribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/")
xml:add_attribute("xmlns:stat", "http://statoconsensirichiesta.xsd.fse.ini.finanze.it")
xml:add_attribute("xmlns:tip", "http://tipodatistatoconsensi.xsd.fse.ini.finanze.it")
xml:update_child_content("soapenv:Header", "")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoUtente", "XXXXXXAAABBBCCC")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:pinCode", "...")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoOrganizzazione", "999")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:StrutturaUtente", "123456789")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:RuoloUtente", "ZZZ")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:ContestoOperativo", "")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoGenitoreTutore", "")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:PresaInCarico", "true")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:TipoAttivita", "READ")
xml:update_child_content("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoConsenso", "ABCDEFGHIJKLM")
local soapEnvelope = xml:get_xml()
local domain = "fseservicetest.sanita.finanze.it"
local path = "/FseInsServicesWeb/services/fseStatoConsensi"
local req = chilkat.HttpRequest.new()
req.http_verb = "POST"
req.send_charset = false
req:add_header("Content-Type", "application/soap+xml; charset=utf-8")
req.path = path
success = req:load_body_from_string(soapEnvelope, "utf-8")
-- Load the default certificate from the smartcard currently in the reader.
-- (This assumes only one reader with one smartcard containing one certificate.
-- If the situation is more complex, you can do it with Chilkat, but it requires
-- using the Chilkat certificate store object to get the desired certificate
-- from the desired smart card.)
--
-- Note: This is for Windows-only.
local cert = chilkat.Cert.new()
success = cert:load_from_smartcard("")
if not success then
print(cert.last_error_text)
return
end
-- Tell the Chilkat HTTP object to use the certificate for client authentication.
success = http:set_ssl_client_cert(cert)
if not success then
print(http.last_error_text)
return
end
http.ssl_protocol = "TLS 1.1"
local resp = chilkat.HttpResponse.new()
success = http:http_sreq(domain, 443, true, req, resp)
if not success then
print(http.last_error_text)
return
end
local xmlResp = chilkat.Xml.new()
success = xmlResp:load_xml(resp.body_str)
print(xmlResp:get_xml())