Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkXmlW.h>
#include <C_CkHttpRequestW.h>
#include <C_CkCertW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkXmlW xml;
const wchar_t *soapEnvelope;
const wchar_t *domain;
const wchar_t *path;
HCkHttpRequestW req;
HCkCertW cert;
HCkHttpResponseW resp;
HCkXmlW xmlResp;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
xml = CkXmlW_Create();
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...
CkXmlW_putTag(xml,L"soapenv:Envelope");
CkXmlW_AddAttribute(xml,L"xmlns:soapenv",L"http://schemas.xmlsoap.org/soap/envelope/");
CkXmlW_AddAttribute(xml,L"xmlns:stat",L"http://statoconsensirichiesta.xsd.fse.ini.finanze.it");
CkXmlW_AddAttribute(xml,L"xmlns:tip",L"http://tipodatistatoconsensi.xsd.fse.ini.finanze.it");
CkXmlW_UpdateChildContent(xml,L"soapenv:Header",L"");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoUtente",L"XXXXXXAAABBBCCC");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:pinCode",L"...");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoOrganizzazione",L"999");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:StrutturaUtente",L"123456789");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:RuoloUtente",L"ZZZ");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:ContestoOperativo",L"");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoGenitoreTutore",L"");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:PresaInCarico",L"true");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:TipoAttivita",L"READ");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoConsenso",L"ABCDEFGHIJKLM");
soapEnvelope = CkXmlW_getXml(xml);
domain = L"fseservicetest.sanita.finanze.it";
path = L"/FseInsServicesWeb/services/fseStatoConsensi";
req = CkHttpRequestW_Create();
CkHttpRequestW_putHttpVerb(req,L"POST");
CkHttpRequestW_putSendCharset(req,FALSE);
CkHttpRequestW_AddHeader(req,L"Content-Type",L"application/soap+xml; charset=utf-8");
CkHttpRequestW_putPath(req,path);
success = CkHttpRequestW_LoadBodyFromString(req,soapEnvelope,L"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.
cert = CkCertW_Create();
success = CkCertW_LoadFromSmartcard(cert,L"");
if (success == FALSE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkHttpW_Dispose(http);
CkXmlW_Dispose(xml);
CkHttpRequestW_Dispose(req);
CkCertW_Dispose(cert);
return;
}
// Tell the Chilkat HTTP object to use the certificate for client authentication.
success = CkHttpW_SetSslClientCert(http,cert);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkXmlW_Dispose(xml);
CkHttpRequestW_Dispose(req);
CkCertW_Dispose(cert);
return;
}
CkHttpW_putTlsVersion(http,L"TLS 1.1");
resp = CkHttpResponseW_Create();
success = CkHttpW_HttpSReq(http,domain,443,TRUE,req,resp);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkXmlW_Dispose(xml);
CkHttpRequestW_Dispose(req);
CkCertW_Dispose(cert);
CkHttpResponseW_Dispose(resp);
return;
}
xmlResp = CkXmlW_Create();
success = CkXmlW_LoadXml(xmlResp,CkHttpResponseW_bodyStr(resp));
wprintf(L"%s\n",CkXmlW_getXml(xmlResp));
CkHttpW_Dispose(http);
CkXmlW_Dispose(xml);
CkHttpRequestW_Dispose(req);
CkCertW_Dispose(cert);
CkHttpResponseW_Dispose(resp);
CkXmlW_Dispose(xmlResp);
}