Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Unicode C Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Unicode C) Belgium eHealth Platform - AddressBook - Search for Professionals

See more Belgian eHealth Platform Examples

Demonstrates how to search for professionals using the AddressBook API.

For more information, see https://www.ehealth.fgov.be/ehealthplatform/nl/data/file/view/6c419e5685327eed7200d1c543c38a55d5387d30?name=AddressBook%20Consultation%20WS%20v.1%20-%20Cookbook%20v.1.11%20dd%2031082023.pdf

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <C_CkCertW.h>
#include <C_CkXmlW.h>
#include <C_CkBinDataW.h>
#include <C_CkDateTimeW.h>
#include <C_CkXmlDSigGenW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkCertW cert;
    HCkXmlW xmlToSign;
    HCkBinDataW bdCert;
    HCkDateTimeW dt;
    HCkXmlDSigGenW gen;
    HCkXmlW xmlCustomKeyInfo;
    HCkStringBuilderW sbXml;
    HCkHttpW http;
    HCkHttpResponseW resp;

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

    success = TRUE;

    // Provide a certificate + private key.
    // Note: If your certificate + private key is located on a hardware token or smartcard, you can call a different function to load from smartcard..
    cert = CkCertW_Create();
    success = CkCertW_LoadPfxFile(cert,L"SSIN=12345678.acc.p12",L"p12_password");
    if (success != TRUE) {
        wprintf(L"%s\n",CkCertW_lastErrorText(cert));
        CkCertW_Dispose(cert);
        return;
    }

    // Create the XML to be signed...

    xmlToSign = CkXmlW_Create();
    CkXmlW_putTag(xmlToSign,L"soapenv:Envelope");
    CkXmlW_AddAttribute(xmlToSign,L"xmlns:soapenv",L"http://schemas.xmlsoap.org/soap/envelope/");
    CkXmlW_AddAttribute(xmlToSign,L"xmlns:urn",L"urn:be:fgov:ehealth:platformintegrationconsumertest:v1");
    CkXmlW_AddAttribute(xmlToSign,L"xmlns:urn1",L"urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1");
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Header|wsse:Security",TRUE,L"xmlns:wsse",L"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Header|wsse:Security",TRUE,L"xmlns:wsu",L"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Header|wsse:Security|wsse:BinarySecurityToken",TRUE,L"EncodingType",L"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Header|wsse:Security|wsse:BinarySecurityToken",TRUE,L"ValueType",L"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Header|wsse:Security|wsse:BinarySecurityToken",TRUE,L"wsu:Id",L"X509-FC77E2C72083DA8E0F16711753508182856");

    // ---------------------------------------------------------------------------------------------------------------
    // A note about the Id's, such as X509-FC77E2C72083DA8E0F16711753508182856, TS-FC77E2C72083DA8E0F16711753508042855, etc.
    // These Id's simply need to be unique within the XML document.  You don't need to generate new Id's every time.
    // You can use the same Id's in each XML document that is submitted. The purpose of each Id is to
    // match the XMLDsig Reference to the element in XML being referenced. 
    // In other words, you could use the Id's "mickey_mouse", "donald_duck", and "goofy", and it would work perfectly OK,
    // as long as no other XML elements also use the Id's "mickey_mouse", "donald_duck", or "goofy"
    // ---------------------------------------------------------------------------------------------------------------

    bdCert = CkBinDataW_Create();
    CkCertW_ExportCertDerBd(cert,bdCert);

    CkXmlW_UpdateChildContent(xmlToSign,L"soapenv:Header|wsse:Security|wsse:BinarySecurityToken",CkBinDataW_getEncoded(bdCert,L"base64"));
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Header|wsse:Security|wsu:Timestamp",TRUE,L"wsu:Id",L"TS-FC77E2C72083DA8E0F16711753508042855");

    dt = CkDateTimeW_Create();
    CkDateTimeW_SetFromCurrentSystemTime(dt);
    CkXmlW_UpdateChildContent(xmlToSign,L"soapenv:Header|wsse:Security|wsu:Timestamp|wsu:Created",CkDateTimeW_getAsTimestamp(dt,FALSE));
    CkDateTimeW_AddSeconds(dt,3600);
    CkXmlW_UpdateChildContent(xmlToSign,L"soapenv:Header|wsse:Security|wsu:Timestamp|wsu:Expires",CkDateTimeW_getAsTimestamp(dt,FALSE));
    CkDateTimeW_AddSeconds(dt,-3600);

    // The body part of the SOAP request to search for professionals looks like this:
    // <soapenv:Body>
    //    <urn:SearchProfessionalsRequest Id="id-FC77E2C72083DA8E0F16711753508182859" IssueInstant="2016-03-23T18:49:26.968+01:00" Offset="0" MaxElements="100">
    //        <urn:SSIN>74062423769</urn:SSIN>
    //    </urn:SearchProfessionalsRequest>
    // </soapenv:Body>

    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Body|urn:SearchProfessionalsRequest",TRUE,L"Id",L"id-FC77E2C72083DA8E0F16711753508182859");
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Body|urn:SearchProfessionalsRequest",TRUE,L"IssueInstant",CkDateTimeW_getAsTimestamp(dt,TRUE));
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Body|urn:SearchProfessionalsRequest",TRUE,L"Offset",L"0");
    CkXmlW_UpdateAttrAt(xmlToSign,L"soapenv:Body|urn:SearchProfessionalsRequest",TRUE,L"MaxElements",L"100");
    CkXmlW_UpdateChildContent(xmlToSign,L"soapenv:Body|urn:SearchProfessionalsRequest|urn:SSIN",L"12345678910");

    gen = CkXmlDSigGenW_Create();

    CkXmlDSigGenW_putSigLocation(gen,L"soapenv:Envelope|soapenv:Header|wsse:Security|wsse:BinarySecurityToken");
    CkXmlDSigGenW_putSigLocationMod(gen,1);
    CkXmlDSigGenW_putSigId(gen,L"SIG-FC77E2C72083DA8E0F16711753508252860");
    CkXmlDSigGenW_putSigNamespacePrefix(gen,L"ds");
    CkXmlDSigGenW_putSigNamespaceUri(gen,L"http://www.w3.org/2000/09/xmldsig#");
    CkXmlDSigGenW_putSignedInfoPrefixList(gen,L"soapenv urn urn1");
    CkXmlDSigGenW_putIncNamespacePrefix(gen,L"ec");
    CkXmlDSigGenW_putIncNamespaceUri(gen,L"http://www.w3.org/2001/10/xml-exc-c14n#");
    CkXmlDSigGenW_putSignedInfoCanonAlg(gen,L"EXCL_C14N");
    CkXmlDSigGenW_putSignedInfoDigestMethod(gen,L"sha256");

    // Set the KeyInfoId before adding references..
    CkXmlDSigGenW_putKeyInfoId(gen,L"KI-FC77E2C72083DA8E0F16711753508182857");

    // -------- Reference 1 --------
    CkXmlDSigGenW_AddSameDocRef(gen,L"TS-FC77E2C72083DA8E0F16711753508042855",L"sha256",L"EXCL_C14N",L"wsse soapenv urn urn1",L"");

    // -------- Reference 2 --------
    CkXmlDSigGenW_AddSameDocRef(gen,L"id-FC77E2C72083DA8E0F16711753508182859",L"sha256",L"EXCL_C14N",L"urn urn1",L"");

    // -------- Reference 3 --------
    CkXmlDSigGenW_AddSameDocRef(gen,L"X509-FC77E2C72083DA8E0F16711753508182856",L"sha256",L"EXCL_C14N",L"_EMPTY_",L"");

    CkXmlDSigGenW_SetX509Cert(gen,cert,TRUE);

    CkXmlDSigGenW_putKeyInfoType(gen,L"Custom");

    // Create the custom KeyInfo XML..
    xmlCustomKeyInfo = CkXmlW_Create();
    CkXmlW_putTag(xmlCustomKeyInfo,L"wsse:SecurityTokenReference");
    CkXmlW_AddAttribute(xmlCustomKeyInfo,L"wsu:Id",L"STR-FC77E2C72083DA8E0F16711753508182858");
    CkXmlW_UpdateAttrAt(xmlCustomKeyInfo,L"wsse:Reference",TRUE,L"URI",L"#X509-FC77E2C72083DA8E0F16711753508182856");
    CkXmlW_UpdateAttrAt(xmlCustomKeyInfo,L"wsse:Reference",TRUE,L"ValueType",L"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");

    CkXmlW_putEmitXmlDecl(xmlCustomKeyInfo,FALSE);
    CkXmlDSigGenW_putCustomKeyInfoXml(gen,CkXmlW_getXml(xmlCustomKeyInfo));

    // Load XML to be signed...
    sbXml = CkStringBuilderW_Create();
    CkXmlW_GetXmlSb(xmlToSign,sbXml);

    CkXmlDSigGenW_putBehaviors(gen,L"IndentedSignature");

    // Sign the XML...
    success = CkXmlDSigGenW_CreateXmlDSigSb(gen,sbXml);
    if (success != TRUE) {
        wprintf(L"%s\n",CkXmlDSigGenW_lastErrorText(gen));
        CkCertW_Dispose(cert);
        CkXmlW_Dispose(xmlToSign);
        CkBinDataW_Dispose(bdCert);
        CkDateTimeW_Dispose(dt);
        CkXmlDSigGenW_Dispose(gen);
        CkXmlW_Dispose(xmlCustomKeyInfo);
        CkStringBuilderW_Dispose(sbXml);
        return;
    }

    // -----------------------------------------------
    // Send the signed XML...
    http = CkHttpW_Create();

    success = CkHttpW_SetSslClientCert(http,cert);
    if (success != TRUE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkCertW_Dispose(cert);
        CkXmlW_Dispose(xmlToSign);
        CkBinDataW_Dispose(bdCert);
        CkDateTimeW_Dispose(dt);
        CkXmlDSigGenW_Dispose(gen);
        CkXmlW_Dispose(xmlCustomKeyInfo);
        CkStringBuilderW_Dispose(sbXml);
        CkHttpW_Dispose(http);
        return;
    }

    CkHttpW_SetRequestHeader(http,L"Content-Type",L"text/xml");
    CkHttpW_SetRequestHeader(http,L"SOAPAction",L"urn:be:fgov:ehealth:addressbook:protocol:v1:searchProfessionals");

    resp = CkHttpW_PostXml(http,L"https://services.ehealth.fgov.be/AddressBook/v1",CkStringBuilderW_getAsString(sbXml),L"utf-8");
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkCertW_Dispose(cert);
        CkXmlW_Dispose(xmlToSign);
        CkBinDataW_Dispose(bdCert);
        CkDateTimeW_Dispose(dt);
        CkXmlDSigGenW_Dispose(gen);
        CkXmlW_Dispose(xmlCustomKeyInfo);
        CkStringBuilderW_Dispose(sbXml);
        CkHttpW_Dispose(http);
        return;
    }

    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    wprintf(L"response status code = %d\n",CkHttpResponseW_getStatusCode(resp));

    CkHttpResponseW_Dispose(resp);


    CkCertW_Dispose(cert);
    CkXmlW_Dispose(xmlToSign);
    CkBinDataW_Dispose(bdCert);
    CkDateTimeW_Dispose(dt);
    CkXmlDSigGenW_Dispose(gen);
    CkXmlW_Dispose(xmlCustomKeyInfo);
    CkStringBuilderW_Dispose(sbXml);
    CkHttpW_Dispose(http);

    }

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.