React Native
React Native
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 React Native Downloads
import { Cert, Http, HttpRequest, HttpResponse, Xml } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new Http();
const xml = new Xml();
// --------------------------------------------------------------------------------
// 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.addAttribute('xmlns:soapenv', 'http://schemas.xmlsoap.org/soap/envelope/');
xml.addAttribute('xmlns:stat', 'http://statoconsensirichiesta.xsd.fse.ini.finanze.it');
xml.addAttribute('xmlns:tip', 'http://tipodatistatoconsensi.xsd.fse.ini.finanze.it');
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 soapEnvelope = xml.getXml();
const domain = 'fseservicetest.sanita.finanze.it';
const path = '/FseInsServicesWeb/services/fseStatoConsensi';
const req = new HttpRequest();
req.httpVerb = 'POST';
req.sendCharset = false;
req.addHeader('Content-Type', 'application/soap+xml; charset=utf-8');
req.path = path;
req.loadBodyFromString(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.
const cert = new Cert();
try {
cert.loadFromSmartcard('');
} catch {
console.log(cert.lastErrorText);
return;
}
// Tell the Chilkat HTTP object to use the certificate for client authentication.
try {
http.setSslClientCert(cert);
} catch {
console.log(http.lastErrorText);
return;
}
http.sslProtocol = 'TLS 1.1';
const resp = new HttpResponse();
try {
await http.httpSReqAsync(domain, 443, true, req, resp);
} catch {
console.log(http.lastErrorText);
return;
}
const xmlResp = new Xml();
xmlResp.loadXml(resp.bodyStr);
console.log(xmlResp.getXml());
}