Sample code for 30+ languages & platforms
SQL Server

Belgium eHealth Platform - checkConnection

See more Belgian eHealth Platform Examples

Demonstrates the first operation of PlatformIntegrationConsumerTest (checkConnection), which has no message-level security and therefore no wsse:Security block in the SOAP header. You test the SSL/TLS connection to the SOA platform.

Chilkat SQL Server Downloads

SQL Server
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

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

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @http, 'SetSslClientCertPfx', @success OUT, 'SSIN=12345678.acc.p12', 'p12_password'
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    -- Create the following XML
    -- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:be:fgov:ehealth:platformintegrationconsumertest:v1"
    -- xmlns:urn1="urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1">
    --     <soapenv:Header/>
    --     <soapenv:Body>
    --         <urn:CheckConnectionRequest>
    --             <urn1:Message>Hello World</urn1:Message>
    --             <urn1:Timestamp>2014-12-30T15:29:03.157+01:00</urn1:Timestamp>
    --         </urn:CheckConnectionRequest>
    --     </soapenv:Body>
    -- </soapenv:Envelope>

    DECLARE @xml int
    EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT

    EXEC sp_OASetProperty @xml, 'Tag', 'soapenv:Envelope'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:soapenv', 'http://schemas.xmlsoap.org/soap/envelope/'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:urn', 'urn:be:fgov:ehealth:platformintegrationconsumertest:v1'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:urn1', 'urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Header', ''
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|urn:CheckConnectionRequest|urn1:Message', 'Hello World'

    -- Create a timestamp with the current date/time in the following format: 2014-12-30T15:29:03.157+01:00
    DECLARE @dt int
    EXEC @hr = sp_OACreate 'Chilkat.CkDateTime', @dt OUT

    EXEC sp_OAMethod @dt, 'SetFromCurrentSystemTime', @success OUT

    EXEC sp_OAMethod @dt, 'GetAsTimestamp', @sTmp0 OUT, 1
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|urn:CheckConnectionRequest|urn1:Timestamp', @sTmp0

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'text/xml'

    DECLARE @resp int
    EXEC @hr = sp_OACreate 'Chilkat.HttpResponse', @resp OUT

    EXEC sp_OAMethod @xml, 'GetXml', @sTmp0 OUT
    EXEC sp_OAMethod @http, 'HttpStr', @success OUT, 'POST', 'https://services-acpt.ehealth.fgov.be/PlatformIntegrationConsumerTest/v1', @sTmp0, 'utf-8', 'application/xml', @resp
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @xml
        EXEC @hr = sp_OADestroy @dt
        EXEC @hr = sp_OADestroy @resp
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT 'response status code = ' + @iTmp0

    -- A successful response is a 200 status code, with this sample response:
    -- 
    -- <?xml version="1.0"?>
    -- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    --    <soapenv:Header xmlns:v1="urn:be:fgov:ehealth:platformintegrationconsumertest:v1" xmlns:v11="urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1"/>
    --    <soapenv:Body xmlns:v1="urn:be:fgov:ehealth:platformintegrationconsumertest:v1" xmlns:v11="urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1">
    --       <ic:CheckConnectionResponse xmlns:ic="urn:be:fgov:ehealth:platformintegrationconsumertest:v1" xmlns:type="urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1">
    --          <type:Message>Hello World</type:Message>
    --          <type:Timestamp>2023-09-28T21:24:32.925+02:00</type:Timestamp>
    --          <type:AuthenticatedConsumer>anonymous</type:AuthenticatedConsumer>
    --       </ic:CheckConnectionResponse>
    --    </soapenv:Body>
    -- </soapenv:Envelope>

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @xml
    EXEC @hr = sp_OADestroy @dt
    EXEC @hr = sp_OADestroy @resp


END
GO