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

Tcl 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
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

 

 

 

(Tcl) Yet Another SOAP MTOM POST Example

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

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

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

set http [new_CkHttp]

# 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>

set xml [new_CkXml]

CkXml_put_Tag $xml "soapenv:Envelope"
CkXml_AddAttribute $xml "xmlns:soapenv" "http://schemas.xmlsoap.org/soap/envelope/"
CkXml_AddAttribute $xml "xmlns:imp" "http://www.yourdomain.it/ImportMultiploWorkflowPAWS/"
CkXml_UpdateChildContent $xml "soapenv:Header" ""
CkXml_UpdateChildContent $xml "soapenv:Body|imp:InputImportMultiploWorkflowPA|usernameEis" "MyUsername"
CkXml_UpdateChildContent $xml "soapenv:Body|imp:InputImportMultiploWorkflowPA|passwordEis" "MyPassword"
CkXml_UpdateChildContent $xml "soapenv:Body|imp:InputImportMultiploWorkflowPA|postazioneEis" "COSO00"
CkXml_UpdateChildContent $xml "soapenv:Body|imp:InputImportMultiploWorkflowPA|istitutoEis" "COSO"
CkXml_UpdateChildContent $xml "soapenv:Body|imp:InputImportMultiploWorkflowPA|codiceAzienda" "COSO0000"
CkXml_UpdateAttrAt $xml "soapenv:Body|imp:InputImportMultiploWorkflowPA|fileZip|inc:Include" 1 "href" "cid:780931946797"
CkXml_UpdateAttrAt $xml "soapenv:Body|imp:InputImportMultiploWorkflowPA|fileZip|inc:Include" 1 "xmlns:inc" "http://www.w3.org/2004/08/xop/include"
CkXml_UpdateChildContent $xml "soapenv:Body|imp:InputImportMultiploWorkflowPA|fileZipName" "IT04769180151_00044.zip"
CkXml_UpdateChildContent $xml "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)

set req [new_CkHttpRequest]

CkHttpRequest_put_HttpVerb $req "POST"
CkHttpRequest_put_Path $req "/http-router-softwarehubsystem/webservices/importMultiploWorkflowPA"
CkHttpRequest_put_ContentType $req "multipart/related; type=\"application/xop+xml\"; start=\"<rootpart@soapui.org>\"; start-info=\"text/xml\""
CkHttpRequest_AddHeader $req "SOAPAction" "\"http://www.yourdomain.it/ImportMultiploWorkflowPAWS/importMultiploWorkflowPA\""
CkHttpRequest_AddHeader $req "Accept-Encoding" "gzip,deflate"
CkHttpRequest_AddHeader $req "Mime-Version" "1.0"
CkHttpRequest_AddHeader $req "Connection" "Keep-Alive"
CkHttpRequest_AddHeader $req "User-Agent" "Apache-HttpClient/4.1.1 (java 1.5)"

# Add the XML content for the 1st MIME sub-part.
CkXml_put_EmitXmlDecl $xml 0
CkXml_put_EmitCompact $xml 0
set success [CkHttpRequest_AddStringForUpload2 $req "" "" [CkXml_getXml $xml] "utf-8" "application/xop+xml; charset=UTF-8; type=\"text/xml\""]

# 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.
set success [CkHttpRequest_AddSubHeader $req 0 "Content-Transfer-Encoding" "8bit"]
set success [CkHttpRequest_AddSubHeader $req 0 "Content-ID" "<rootpart@soapui.org>"]

# Add a reference to the local file for the file data for the 2nd MIME sub-part.
set success [CkHttpRequest_AddFileForUpload2 $req "" "qa_data/zips/helloWorld.zip" "application/zip; name=IT04769180151_00044.zip"]

# 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.
set success [CkHttpRequest_AddSubHeader $req 1 "Content-Transfer-Encoding" "binary"]
set success [CkHttpRequest_AddSubHeader $req 1 "Content-ID" "<IT04769180151_00044.zip>"]
set success [CkHttpRequest_AddSubHeader $req 1 "Content-Disposition" "attachment; name=\"IT04769180151_00044.zip\"; filename=\"IT04769180151_00044.zip\""]

# Keep a session log so we can examine the exact request/response.
# Remove this line when finished with debugging.
CkHttp_put_SessionLogFilename $http "qa_output/mtom_sessionLog.txt"

set useTls 0
# Note: Please don't run this example without changing the domain to your own domain...
# resp is a CkHttpResponse
set resp [CkHttp_SynchronousRequest $http "www.yourdomain.it" 80 $useTls $req]
if {[CkHttp_get_LastMethodSuccess $http] != 1} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkXml $xml
    delete_CkHttpRequest $req
    exit
}

set xmlResponse [new_CkXml]

set success [CkXml_LoadXml $xmlResponse [CkHttpResponse_bodyStr $resp]]
# println xmlResponse.GetXml();
delete_CkHttpResponse $resp

puts "OK."

delete_CkHttp $http
delete_CkXml $xml
delete_CkHttpRequest $req
delete_CkXml $xmlResponse

 

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