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
Cloud Signature CSC
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
Secrets
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) Yet Another SOAP MTOM POST Example

Demonstrates how to sending a SOAP request with an MTOM/XOP attachment...

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Handle hoXml
    Variant vReq
    Handle hoReq
    Boolean iUseTls
    Variant vResp
    Handle hoResp
    Handle hoXmlResponse
    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(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // First build the following XML:

    // 	<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    // 	    xmlns:imp="http://www.yourdomain.it/ImportMultiploWorkflowPAWS/">
    // 	   <soapenv:Header/>
    // 	   <soapenv:Body>
    // 	      <imp:InputImportMultiploWorkflowPA>
    // 	         <usernameEis>MyUsername</usernameEis>
    // 	         <passwordEis>MyPassword</passwordEis>
    // 	         <postazioneEis>COSO00</postazioneEis>
    // 	         <istitutoEis>COSO</istitutoEis>
    // 	         <codiceAzienda>COSO0000</codiceAzienda>
    // 	         <fileZip><inc:Include href="cid:780931946797" xmlns:inc="http://www.w3.org/2004/08/xop/include"/></fileZip>
    // 	         <fileZipName>IT04769180151_00044.zip</fileZipName>
    // 	         <workflow>carica</workflow>
    // 	      </imp:InputImportMultiploWorkflowPA>
    // 	   </soapenv:Body>
    // 	</soapenv:Envelope>

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Set ComTag Of hoXml To "soapenv:Envelope"
    Get ComAddAttribute Of hoXml "xmlns:soapenv" "http://schemas.xmlsoap.org/soap/envelope/" To iSuccess
    Get ComAddAttribute Of hoXml "xmlns:imp" "http://www.yourdomain.it/ImportMultiploWorkflowPAWS/" To iSuccess
    Send ComUpdateChildContent To hoXml "soapenv:Header" ""
    Send ComUpdateChildContent To hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|usernameEis" "MyUsername"
    Send ComUpdateChildContent To hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|passwordEis" "MyPassword"
    Send ComUpdateChildContent To hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|postazioneEis" "COSO00"
    Send ComUpdateChildContent To hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|istitutoEis" "COSO"
    Send ComUpdateChildContent To hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|codiceAzienda" "COSO0000"
    Get ComUpdateAttrAt Of hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|fileZip|inc:Include" True "href" "cid:780931946797" To iSuccess
    Get ComUpdateAttrAt Of hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|fileZip|inc:Include" True "xmlns:inc" "http://www.w3.org/2004/08/xop/include" To iSuccess
    Send ComUpdateChildContent To hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|fileZipName" "IT04769180151_00044.zip"
    Send ComUpdateChildContent To hoXml "soapenv:Body|imp:InputImportMultiploWorkflowPA|workflow" "carica"

    // We want our top-level HTTP request header to look like this:

    // POST /http-router-softwarehubsystem/webservices/importMultiploWorkflowPA HTTP/1.1
    // Accept-Encoding: gzip,deflate
    // Content-Type: multipart/related; type="application/xop+xml"; start="<rootpart@soapui.org>"; start-info="text/xml"; boundary="----=_Part_0_1353857996.1546013984933"
    // SOAPAction: "http://www.yourdomain.it/ImportMultiploWorkflowPAWS/importMultiploWorkflowPA"
    // MIME-Version: 1.0
    // Content-Length: <chilkat will add this header>
    // Host: <chilkat will add this header>
    // Connection: Keep-Alive
    // User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End
    Set ComHttpVerb Of hoReq To "POST"
    Set ComPath Of hoReq To "/http-router-softwarehubsystem/webservices/importMultiploWorkflowPA"
    Set ComContentType Of hoReq To 'multipart/related; type="application/xop+xml"; start="<rootpart@soapui.org>"; start-info="text/xml"'
    Send ComAddHeader To hoReq "SOAPAction" '"http://www.yourdomain.it/ImportMultiploWorkflowPAWS/importMultiploWorkflowPA"'
    Send ComAddHeader To hoReq "Accept-Encoding" "gzip,deflate"
    Send ComAddHeader To hoReq "Mime-Version" "1.0"
    Send ComAddHeader To hoReq "Connection" "Keep-Alive"
    Send ComAddHeader To hoReq "User-Agent" "Apache-HttpClient/4.1.1 (java 1.5)"

    // Add the XML content for the 1st MIME sub-part.
    Set ComEmitXmlDecl Of hoXml To False
    Set ComEmitCompact Of hoXml To False
    Get ComGetXml Of hoXml To sTemp1
    Get ComAddStringForUpload2 Of hoReq "" "" sTemp1 "utf-8" 'application/xop+xml; charset=UTF-8; type="text/xml"' To iSuccess

    // We want the 1st sub-header (the sub-part containing the XML) to look like this:

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

    // Make sure we set sub-headers *after* calling AddStringForUpload2, otherwise AddStringForUpload2 might change these explicitly set headers.
    Get ComAddSubHeader Of hoReq 0 "Content-Transfer-Encoding" "8bit" To iSuccess
    Get ComAddSubHeader Of hoReq 0 "Content-ID" "<rootpart@soapui.org>" To iSuccess

    // Add a reference to the local file for the file data for the 2nd MIME sub-part.
    Get ComAddFileForUpload2 Of hoReq "" "qa_data/zips/helloWorld.zip" "application/zip; name=IT04769180151_00044.zip" To iSuccess

    // We want the 2nd sub-header (for the MIME sub-part containing a .zip file) to look like this:
    // Content-Type: application/zip; name=IT04769180151_00044.zip
    // Content-Transfer-Encoding: binary
    // Content-ID: <IT04769180151_00044.zip>
    // Content-Disposition: attachment; name="IT04769180151_00044.zip"; filename="IT04769180151_00044.zip"

    // Make sure we set sub-headers *after* calling AddFileForUpload2, otherwise AddFileForUpload2 might change these explicitly set headers.
    Get ComAddSubHeader Of hoReq 1 "Content-Transfer-Encoding" "binary" To iSuccess
    Get ComAddSubHeader Of hoReq 1 "Content-ID" "<IT04769180151_00044.zip>" To iSuccess
    Get ComAddSubHeader Of hoReq 1 "Content-Disposition" 'attachment; name="IT04769180151_00044.zip"; filename="IT04769180151_00044.zip"' To iSuccess

    // Keep a session log so we can examine the exact request/response.
    // Remove this line when finished with debugging.
    Set ComSessionLogFilename Of hoHttp To "qa_output/mtom_sessionLog.txt"

    Move False To iUseTls
    // Note: Please don't run this example without changing the domain to your own domain...
    Get pvComObject of hoReq to vReq
    Get ComSynchronousRequest Of hoHttp "www.yourdomain.it" 80 iUseTls vReq To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatXml)) To hoXmlResponse
    If (Not(IsComObjectCreated(hoXmlResponse))) Begin
        Send CreateComObject of hoXmlResponse
    End
    Get ComBodyStr Of hoResp To sTemp1
    Get ComLoadXml Of hoXmlResponse sTemp1 To iSuccess
    // println xmlResponse.GetXml();
    Send Destroy of hoResp

    Showln "OK."


End_Procedure

 

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