Sample code for 30+ languages & platforms
Rust

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 Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let http = chilkat::Http::new();
let xml = chilkat::Xml::new();

let _ = 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.set_tag("soapenv:Envelope");
let _ = xml.add_attribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
let _ = xml.add_attribute("xmlns:stat", "http://statoconsensirichiesta.xsd.fse.ini.finanze.it");
let _ = 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");
let soap_envelope = xml.get_xml().unwrap_or_default();

let domain = "fseservicetest.sanita.finanze.it".to_string();
let path = "/FseInsServicesWeb/services/fseStatoConsensi".to_string();

let req = chilkat::HttpRequest::new();
req.set_http_verb("POST");
req.set_send_charset(false);
req.add_header("Content-Type", "application/soap+xml; charset=utf-8");
req.set_path(&path);
let _ = req.load_body_from_string(&soap_envelope, "utf-8").is_ok();

// 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.
let cert = chilkat::Cert::new();
if cert.load_from_smartcard("").is_err() {
    println!("{}", cert.last_error_text());
    return;
}

// Tell the Chilkat HTTP object to use the certificate for client authentication.
if http.set_ssl_client_cert(&cert).is_err() {
    println!("{}", http.last_error_text());
    return;
}

http.set_ssl_protocol("TLS 1.1");

let resp = chilkat::HttpResponse::new();
if http.http_s_req(&domain, 443, true, &req, &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

let xml_resp = chilkat::Xml::new();
let _ = xml_resp.load_xml(&resp.body_str()).is_ok();
println!("{}", xml_resp.get_xml().unwrap_or_default());