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

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) BaFin MVP Portal SOAP Web Service MTOM

Demonstrate how to send a SOAP request with MTOM attachment to the BaFin MVP Portal as indicated at https://www.bafin.de/SharedDocs/Downloads/EN/dl_mvp-portal_soap_webservice_a26mifir_en.pdf

For more information, see https://www.bafin.de/SharedDocs/Downloads/EN/dl_mvp-portal_soap_webservice_a26mifir_en.pdf

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    Boolean iSuccess
    Handle hoSoapXml
    String sResponseBody
    Variant vBdRequest
    Handle hoBdRequest
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    // Connect to portal.mvp.bafin.de:444
    Move True To iBTls
    Move 444 To iPort
    Move True To iBAutoReconnect
    Get ComConnect Of hoRest "portal.mvp.bafin.de" iPort iBTls iBAutoReconnect To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // The SOAP request we'll be sending is multipart/related and it will have two parts
    // 1) the SOAP Envelope
    // 2) the MTOM attachment (in this case an XML document)

    // Let's build the SOAP envelope:
    // Note: The data posted here, including the username, are not actual accounts.  It is the sample data provided
    // at https://www.bafin.de/SharedDocs/Downloads/EN/dl_mvp-portal_soap_webservice_a26mifir_en.pdf

    // Use this online tool to generate code from sample XML: 
    // Generate Code to Create XML

    Get Create (RefClass(cComChilkatXml)) To hoSoapXml
    If (Not(IsComObjectCreated(hoSoapXml))) Begin
        Send CreateComObject of hoSoapXml
    End
    Set ComTag Of hoSoapXml To "soapenv:Envelope"
    Get ComAddAttribute Of hoSoapXml "xmlns:a26mifir" "http://www.bafin.de/mvp/a26mifir/" To iSuccess
    Get ComAddAttribute Of hoSoapXml "xmlns:soapenv" "http://schemas.xmlsoap.org/soap/envelope/" To iSuccess
    Get ComUpdateAttrAt Of hoSoapXml "soapenv:Header|wsse:Security" True "soapenv:mustUnderstand" "1" To iSuccess
    Get ComUpdateAttrAt Of hoSoapXml "soapenv:Header|wsse:Security" True "xmlns:wsse" "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" To iSuccess
    Get ComUpdateAttrAt Of hoSoapXml "soapenv:Header|wsse:Security" True "xmlns:wsu" "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurityutility-1.0.xsd" To iSuccess
    Get ComUpdateAttrAt Of hoSoapXml "soapenv:Header|wsse:Security|wsse:UsernameToken" True "wsu:Id" "UsernameToken44C3662D584567FE6A14672949268541" To iSuccess
    Send ComUpdateChildContent To hoSoapXml "soapenv:Header|wsse:Security|wsse:UsernameToken|wsse:Username" "karl.meier1234#hg_05_1234567890"
    Get ComUpdateAttrAt Of hoSoapXml "soapenv:Header|wsse:Security|wsse:UsernameToken|wsse:Password" True "Type" "http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-username-token-profile-1.0#PasswordText" To iSuccess
    Send ComUpdateChildContent To hoSoapXml "soapenv:Header|wsse:Security|wsse:UsernameToken|wsse:Password" "XXXXXXXXXX"
    Get ComUpdateAttrAt Of hoSoapXml "soapenv:Header|wsse:Security|wsse:UsernameToken|wsse:Nonce" True "EncodingType" "http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-soap-message-security1.0#Base64Binary" To iSuccess
    Send ComUpdateChildContent To hoSoapXml "soapenv:Header|wsse:Security|wsse:UsernameToken|wsse:Nonce" "+WifMh5kFw/1fHgMahFu7A=="
    Send ComUpdateChildContent To hoSoapXml "soapenv:Header|wsse:Security|wsse:UsernameToken|wsu:Created" "2016-06-30T13:55:26.852Z"
    Send ComUpdateChildContent To hoSoapXml "soapenv:Body|a26mifir:submitDATTRA|inDATTRA|a26mifir:dateiname" "A26MiFIR_Testfile_001.xml"
    Send ComUpdateChildContent To hoSoapXml "soapenv:Body|a26mifir:submitDATTRA|kundenreferenz" "ClientRef_001"
    Get ComUpdateAttrAt Of hoSoapXml "soapenv:Body|a26mifir:submitDATTRA|datei|inc:Include" True "href" "cid:139580394822" To iSuccess
    Get ComUpdateAttrAt Of hoSoapXml "soapenv:Body|a26mifir:submitDATTRA|datei|inc:Include" True "xmlns:inc" "http://www.w3.org/2004/08/xop/include" To iSuccess

    // We built the following XML:

    // <?xml version="1.0" encoding="utf-8"?>
    // <soapenv:Envelope xmlns:a26mifir="http://www.bafin.de/mvp/a26mifir/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    //     <soapenv:Header>
    //         <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurityutility-1.0.xsd">
    //             <wsse:UsernameToken wsu:Id="UsernameToken44C3662D584567FE6A14672949268541">
    //                 <wsse:Username>karl.meier1234#hg_05_1234567890</wsse:Username>
    //                 <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-username-token-profile-1.0#PasswordText">XXXXXXXXXX</wsse:Password>
    //                 <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-soap-message-security1.0#Base64Binary">+WifMh5kFw/1fHgMahFu7A==</wsse:Nonce>
    //                 <wsu:Created>2016-06-30T13:55:26.852Z</wsu:Created>
    //             </wsse:UsernameToken>
    //         </wsse:Security>
    //     </soapenv:Header>
    //     <soapenv:Body>
    //         <a26mifir:submitDATTRA>
    //             <inDATTRA>
    //                 <a26mifir:dateiname>A26MiFIR_Testfile_001.xml</a26mifir:dateiname>
    //             </inDATTRA>
    //             <kundenreferenz>ClientRef_001</kundenreferenz>
    //             <datei>
    //                 <inc:Include href="cid:139580394822" xmlns:inc="http://www.w3.org/2004/08/xop/include"/>
    //             </datei>
    //         </a26mifir:submitDATTRA>
    //     </soapenv:Body>
    // </soapenv:Envelope>

    // ------------------------------------------------------------
    // We want the top-most header of our request to look like this:

    // POST https://portal.mvp.bafin.de:444/services/ws/t_a26mifir HTTP/1.1
    // Content-Encoding: gzip
    // Accept-Encoding: gzip,deflate
    // Content-Type: multipart/related; type="application/xop+xml";
    //    start="<rootpart@soapui.org>"; start-info="text/xml"; boundary="----=_Part_3_19706996.1467294979823"
    // SOAPAction: "http://www.bafin.de/mvp/a26mifir/submitDATTRA"
    // MIME-Version: 1.0
    // Transfer-Encoding: chunked
    // Host: portal.mvp.bafin.de:444
    // Connection: Keep-Alive
    // User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

    // Some header fields are unimportant.  
    // 1) We can omit the User-Agent.
    // 2) Also, the Transfer-Encoding doesn't need to be "chunked".  It shouldn't matter whether it's chunked or non-chunked.
    // 3) We do need the Content-Encoding to be "gzip", because the documentation at https://www.bafin.de/SharedDocs/Downloads/EN/dl_mvp-portal_soap_webservice_a26mifir_en.pdf
    // explicitly states that it wants a gzip compressed request body.
    // 4) Don't worry about specifying a boundary.  Chilkat will auto-generate a boundary and add it to the Content-Type.
    // 5) If we're sending many requests on the same connection, then set the Connection: Keep-Alive header.  Otherwise, there is no need for it.

    // Begin specifying header fields for the topmost header:
    Get ComAddHeader Of hoRest "Content-Type" 'multipart/related; type="application/xop+xml"; start="<rootpart@soapui.org>"; start-info="text/xml"' To iSuccess
    Get ComAddHeader Of hoRest "Content-Encoding" "gzip" To iSuccess
    Get ComAddHeader Of hoRest "Accept-Encoding" "gzip,deflate" To iSuccess
    Get ComAddHeader Of hoRest "SOAPAction" "http://www.bafin.de/mvp/a26mifir/submitDATTRA" To iSuccess
    Get ComAddHeader Of hoRest "MIME-Version" "1.0" To iSuccess
    Get ComAddHeader Of hoRest "Connection" "Keep-Alive" To iSuccess

    // ------------------------------------------------------------
    // Build the header for the 1st sub-part, which will contain the SOAP envelope.
    // It will look like this:

    // Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
    // Content-Transfer-Encoding: 8bit
    // Content-ID: <rootpart@soapui.org>

    Set ComPartSelector Of hoRest To "1"
    Get ComAddHeader Of hoRest "Content-Type" 'application/xop+xml; charset=UTF-8; type="text/xml"' To iSuccess
    Get ComAddHeader Of hoRest "Content-Transfer-Encoding" "8bit" To iSuccess
    Get ComAddHeader Of hoRest "Content-ID" "<rootpart@soapui.org>" To iSuccess
    Set ComEmitCompact Of hoSoapXml To True
    Set ComEmitXmlDecl Of hoSoapXml To False
    Get ComGetXml Of hoSoapXml To sTemp1
    Get ComSetMultipartBodyString Of hoRest sTemp1 To iSuccess

    // ------------------------------------------------------------
    // Build the header for the 1st sub-part, which will contain the SOAP envelope.
    // It will look like this:

    // Content-Type: application/octet-binary; name=A26MiFIR_Testfile_001.xml
    // Content-Transfer-Encoding: binary
    // Content-ID: <139580394822>
    // Content-Disposition: attachment; name=" A26MiFIR_Testfile_001.xml"; filename="A26MiFIR_Testfile_001.xml"

    Set ComPartSelector Of hoRest To "2"
    Get ComAddHeader Of hoRest "Content-Type" "application/octet-binary; name=A26MiFIR_Testfile_001.xml" To iSuccess
    Get ComAddHeader Of hoRest "Content-Transfer-Encoding" "binary" To iSuccess
    Get ComAddHeader Of hoRest "Content-ID" "<139580394822>" To iSuccess
    Get ComAddHeader Of hoRest "Content-Disposition" 'attachment; name="A26MiFIR_Testfile_001.xml"; filename="A26MiFIR_Testfile_001.xml"' To iSuccess

    // We'll just use a fake attachment XML body for this example
    Get ComSetMultipartBodyString Of hoRest "<test>blah blah blah</test>" To iSuccess

    // ------------------------------------------------------------
    // The request is fully specified.  Now send the POST...

    // Turn on DebugMode.  This is a mode where no request is sent.  Instead, the request that would've been
    // sent is recorded and can be retrieved via the GetLastDebugRequest method.
    Set ComDebugMode Of hoRest To True

    Get ComFullRequestMultipart Of hoRest "POST" "/services/ws/t_a26mifir" To sResponseBody
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Because we set DebugMode, no request was actually sent.  Instead, we can examine the exact
    // request that would've been sent:
    Get ComDebugMode Of hoRest To bTemp1
    If (bTemp1 = True) Begin
        Get Create (RefClass(cComChilkatBinData)) To hoBdRequest
        If (Not(IsComObjectCreated(hoBdRequest))) Begin
            Send CreateComObject of hoBdRequest
        End
        Get pvComObject of hoBdRequest to vBdRequest
        Get ComGetLastDebugRequest Of hoRest vBdRequest To iSuccess
        Get ComWriteFile Of hoBdRequest "qa_output/bafin_request.txt" To iSuccess
    End

    Showln "Success."

    // Clear the REST object for any subsequent requests..
    Get ComClearAllHeaders Of hoRest To iSuccess
    Get ComClearAllParts Of hoRest To iSuccess
    Set ComPartSelector Of hoRest To ""


End_Procedure

 

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