C
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 C Downloads
#include <C_CkHttp.h>
#include <C_CkXml.h>
#include <C_CkHttpRequest.h>
#include <C_CkCert.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttp http;
HCkXml xml;
const char *soapEnvelope;
const char *domain;
const char *path;
HCkHttpRequest req;
HCkCert cert;
HCkHttpResponse resp;
HCkXml xmlResp;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
xml = CkXml_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...
CkXml_putTag(xml,"soapenv:Envelope");
CkXml_AddAttribute(xml,"xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/");
CkXml_AddAttribute(xml,"xmlns:stat","http://statoconsensirichiesta.xsd.fse.ini.finanze.it");
CkXml_AddAttribute(xml,"xmlns:tip","http://tipodatistatoconsensi.xsd.fse.ini.finanze.it");
CkXml_UpdateChildContent(xml,"soapenv:Header","");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoUtente","XXXXXXAAABBBCCC");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:pinCode","...");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoOrganizzazione","999");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:StrutturaUtente","123456789");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:RuoloUtente","ZZZ");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:ContestoOperativo","");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoGenitoreTutore","");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:PresaInCarico","true");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:TipoAttivita","READ");
CkXml_UpdateChildContent(xml,"soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoConsenso","ABCDEFGHIJKLM");
soapEnvelope = CkXml_getXml(xml);
domain = "fseservicetest.sanita.finanze.it";
path = "/FseInsServicesWeb/services/fseStatoConsensi";
req = CkHttpRequest_Create();
CkHttpRequest_putHttpVerb(req,"POST");
CkHttpRequest_putSendCharset(req,FALSE);
CkHttpRequest_AddHeader(req,"Content-Type","application/soap+xml; charset=utf-8");
CkHttpRequest_putPath(req,path);
success = CkHttpRequest_LoadBodyFromString(req,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.
cert = CkCert_Create();
success = CkCert_LoadFromSmartcard(cert,"");
if (success == FALSE) {
printf("%s\n",CkCert_lastErrorText(cert));
CkHttp_Dispose(http);
CkXml_Dispose(xml);
CkHttpRequest_Dispose(req);
CkCert_Dispose(cert);
return;
}
// Tell the Chilkat HTTP object to use the certificate for client authentication.
success = CkHttp_SetSslClientCert(http,cert);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkXml_Dispose(xml);
CkHttpRequest_Dispose(req);
CkCert_Dispose(cert);
return;
}
CkHttp_putTlsVersion(http,"TLS 1.1");
resp = CkHttpResponse_Create();
success = CkHttp_HttpSReq(http,domain,443,TRUE,req,resp);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkXml_Dispose(xml);
CkHttpRequest_Dispose(req);
CkCert_Dispose(cert);
CkHttpResponse_Dispose(resp);
return;
}
xmlResp = CkXml_Create();
success = CkXml_LoadXml(xmlResp,CkHttpResponse_bodyStr(resp));
printf("%s\n",CkXml_getXml(xmlResp));
CkHttp_Dispose(http);
CkXml_Dispose(xml);
CkHttpRequest_Dispose(req);
CkCert_Dispose(cert);
CkHttpResponse_Dispose(resp);
CkXml_Dispose(xmlResp);
}