Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) SOAP Request to fseservicetest.sanita.finanze.it with Smart Card Authentication (TS-CNS Italian Card)Demonstrates sending a SOAP request to fseservicetest.sanita.finanze.it with Smart Card (TS-CNS Italian Card).
#include <C_CkHttpW.h> #include <C_CkXmlW.h> #include <C_CkHttpRequestW.h> #include <C_CkCertW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { HCkHttpW http; HCkXmlW xml; BOOL success; const wchar_t *soapEnvelope; const wchar_t *domain; const wchar_t *path; HCkHttpRequestW req; HCkCertW cert; HCkHttpResponseW resp; HCkXmlW xmlResp; // 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 = CkHttpW_SynchronousRequest(http,domain,443,TRUE,req); if (CkHttpW_getLastMethodSuccess(http) == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkXmlW_Dispose(xml); CkHttpRequestW_Dispose(req); CkCertW_Dispose(cert); return; } xmlResp = CkXmlW_Create(); success = CkXmlW_LoadXml(xmlResp,CkHttpResponseW_bodyStr(resp)); wprintf(L"%s\n",CkXmlW_getXml(xmlResp)); CkHttpResponseW_Dispose(resp); CkHttpW_Dispose(http); CkXmlW_Dispose(xml); CkHttpRequestW_Dispose(req); CkCertW_Dispose(cert); CkXmlW_Dispose(xmlResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.