Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
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
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(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-9.5.0-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" "binar" 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-2019 Chilkat Software, Inc. All Rights Reserved.