Zig
Zig
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 Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = try chilkat.Http.init();
defer http.deinit();
const xml = try chilkat.Xml.init();
defer xml.deinit();
// --------------------------------------------------------------------------------
// 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.setTag("soapenv:Envelope");
xml.addAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/") catch {};
xml.addAttribute("xmlns:stat", "http://statoconsensirichiesta.xsd.fse.ini.finanze.it") catch {};
xml.addAttribute("xmlns:tip", "http://tipodatistatoconsensi.xsd.fse.ini.finanze.it") catch {};
xml.updateChildContent("soapenv:Header", "");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoUtente", "XXXXXXAAABBBCCC");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:pinCode", "...");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoOrganizzazione", "999");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:StrutturaUtente", "123456789");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:RuoloUtente", "ZZZ");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:ContestoOperativo", "");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoGenitoreTutore", "");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:PresaInCarico", "true");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:TipoAttivita", "READ");
xml.updateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoConsenso", "ABCDEFGHIJKLM");
const soap_envelope = try xml.getXml(alloc);
const domain = "fseservicetest.sanita.finanze.it";
const path = "/FseInsServicesWeb/services/fseStatoConsensi";
const req = try chilkat.HttpRequest.init();
defer req.deinit();
req.setHttpVerb("POST");
req.setSendCharset(false);
req.addHeader("Content-Type", "application/soap+xml; charset=utf-8");
req.setPath(path);
try req.loadBodyFromString(soap_envelope, "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.
const cert = try chilkat.Cert.init();
defer cert.deinit();
cert.loadFromSmartcard("") catch {
std.debug.print("{s}\n", .{try cert.getLastErrorText(alloc)});
return;
};
// Tell the Chilkat HTTP object to use the certificate for client authentication.
http.setSslClientCert(cert) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
http.setSslProtocol("TLS 1.1");
const resp = try chilkat.HttpResponse.init();
defer resp.deinit();
http.httpSReq(domain, 443, true, req, resp) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
const xml_resp = try chilkat.Xml.init();
defer xml_resp.deinit();
try xml_resp.loadXml(try resp.getBodyStr(alloc));
std.debug.print("{s}\n", .{try xml_resp.getXml(alloc)});
}