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

VBScript 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
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
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 Encryption
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

 

 

 

(VBScript) Azure Service Bus - Receive and Delete Message from Subscription

Shows how to receive and delete a message from an Azure service bus topic subscription.

Note: This example requires Chilkat v9.5.0.65 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

'  Note: Requires Chilkat v9.5.0.65 or greater.

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

'  Make the initial connection.
'  A single REST object, once connected, can be used for many Azure Service Bus REST API calls.
'  The auto-reconnect indicates that if the already-established HTTPS connection is closed,
'  then it will be automatically re-established as needed.
set rest = CreateObject("Chilkat_9_5_0.Rest")
bAutoReconnect = 1
success = rest.Connect("<yournamespace>.servicebus.windows.net",443,1,bAutoReconnect)
If (success <> 1) Then
    outFile.WriteLine(rest.LastErrorText)
    WScript.Quit
End If

'  ----------------------------------------------------------------------------------------------
'  The code above this comment could be placed inside a function/subroutine within the application
'  because the connection does not need to be made for every request.  Once the connection is made
'  the app may send many requests..
'  ----------------------------------------------------------------------------------------------

'  Let's load a previously computed SAS token and use it.
'  See Azure Shared Access Signature for an example to genenerate an Azure SAS token.
set sbToken = CreateObject("Chilkat_9_5_0.StringBuilder")
success = sbToken.LoadFile("qa_data/tokens/serviceBusSas.txt","utf-8")

'  Tell the REST object to use the Azure Shared Access Signature for authorization.
success = sbToken.Prepend("SharedAccessSignature ")
success = rest.AddHeader("Authorization",sbToken.GetAsString())

'  ----------------------------------------------------------------------------------------------

'  Receive a message from the subscription "feedings" in the topic "gilaMonster"
topicName = "gilaMonster"
subscriptionName = "feedings"

'  Build the path..
set sbPath = CreateObject("Chilkat_9_5_0.StringBuilder")
success = sbPath.Append("/")
success = sbPath.Append(topicName)
success = sbPath.Append("/subscriptions/")
success = sbPath.Append(subscriptionName)
success = sbPath.Append("/messages/head")

'  Add a timeout parameter.
success = rest.AddQueryParam("timeout","60")

'  Use the DELETE HTTP verb to read the message at the head of the queue and remove it.
set sbResponseBody = CreateObject("Chilkat_9_5_0.StringBuilder")
success = rest.FullRequestNoBodySb("DELETE",sbPath.GetAsString(),sbResponseBody)
If (success <> 1) Then
    outFile.WriteLine(rest.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine("Response Status Code = " & rest.ResponseStatusCode)

'  Check for a success response.
If (rest.ResponseStatusCode <> 200) Then
    outFile.WriteLine(rest.LastRequestStartLine)
    outFile.WriteLine(rest.LastRequestHeader)
    outFile.WriteLine(sbResponseBody.GetAsString())
    outFile.WriteLine("Failed.")
    WScript.Quit
End If

'  If successful, the message is the contents of the response body.
message = sbResponseBody.GetAsString()
outFile.WriteLine("Received message: " & message)

outFile.WriteLine("Success.")

outFile.Close

 

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