Amazon SNS: Send an SMS Directly to an E.164 Phone Number
See more Amazon SNS Examples
Uses the current Amazon SNS Query API (Version=2010-03-31) through Chilkat.Rest and AuthAws, with HTTPS, Signature Version 4, and service sns. The API version date remains current. Action and input parameters are URL-encoded into a POST body, avoiding message text and recipient addresses in the URL. Set the actual region once; other AWS partitions need their documented endpoint suffix and ARN partition.
Load private qa_data/aws/sns.json with nonempty string fields access_key, secret_key, and session_token when using temporary credentials. Prefer short-lived role credentials. This sample does not discover profiles, obtain credentials, or refresh them automatically. The session token is included in the signed form body on every request. A Socket explicitly enables TLS certificate verification before passing the connection to Rest.
Checks setup calls, transport completion, HTTP status, XML parsing, result root, and required fields. Normal output includes identifiers, not full messages or headers. Keep detailed diagnostics private. For retryable failures, use bounded backoff with jitter in the application; these examples do not automatically retry writes. A Publish timeout can leave an accepted message and retrying a standard-topic/SMS publish can duplicate it. A returned MessageId confirms SNS acceptance, not subscriber or handset delivery.
Use an authorized recipient in E.164 format. New SMS accounts start in the regional SMS sandbox and can send only to verified destinations. Origination identities, country support, registration, spending limits and opt-out status can affect delivery. Confirm the appropriate configuration with SNS SMS sandbox guidance and SNS SMS sending guidance.
Messages can be segmented and billed as multiple SMS messages; encoding affects segment size. The sample chooses AWS.SNS.SMS.SMSType=Transactional for a transactional test message; choose a type appropriate to the actual use. A MessageId is not a delivery receipt. Direct SMS uses PhoneNumber without TopicArn or TargetArn. There is no need to create a topic or subscription for a direct send.
The local input check limits the message to 1,600 characters but does not predict segment count or cost. The example sets only PhoneNumber as its destination; it does not publish to a topic at the same time.
Required IAM action: sns:Publish. Grant only the intended resource access; direct SMS does not have a topic ARN resource. Topic policies and KMS key access can also affect requests.
Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @iTmp1 int
DECLARE @iTmp2 int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @stringCompare int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @stringCompare OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Assumes Chilkat is unlocked. See Global Unlock Sample.
-- Private credentials; do not put this file in public web content or source control.
DECLARE @credentials int
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @credentials OUT
EXEC sp_OASetProperty @credentials, 'Strict', 1
EXEC sp_OAMethod @credentials, 'LoadFile', @success OUT, 'qa_data/aws/sns.json'
IF @success <> 1
BEGIN
PRINT 'Could not load private SNS credentials.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
RETURN
END
EXEC sp_OAMethod @credentials, 'StringOf', @sTmp0 OUT, 'access_key'
EXEC sp_OAMethod @stringCompare, 'SetString', @success OUT, @sTmp0
DECLARE @stringMatch1 int
EXEC sp_OAMethod @stringCompare, 'ContentsEqual', @stringMatch1 OUT, '', 1
EXEC sp_OAMethod @credentials, 'JsonTypeOf', @iTmp0 OUT, 'access_key'
IF (@iTmp0 <> 1) or (@stringMatch1 = 1)
BEGIN
PRINT 'Missing or invalid access_key.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
RETURN
END
EXEC sp_OAMethod @credentials, 'StringOf', @sTmp0 OUT, 'secret_key'
EXEC sp_OAMethod @stringCompare, 'SetString', @success OUT, @sTmp0
DECLARE @stringMatch2 int
EXEC sp_OAMethod @stringCompare, 'ContentsEqual', @stringMatch2 OUT, '', 1
EXEC sp_OAMethod @credentials, 'JsonTypeOf', @iTmp0 OUT, 'secret_key'
IF (@iTmp0 <> 1) or (@stringMatch2 = 1)
BEGIN
PRINT 'Missing or invalid secret_key.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
RETURN
END
DECLARE @region nvarchar(4000)
SELECT @region = 'us-west-2'
DECLARE @endpoint int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @endpoint OUT
EXEC sp_OAMethod @endpoint, 'Append', @success OUT, 'sns.'
EXEC sp_OAMethod @endpoint, 'Append', @success OUT, @region
EXEC sp_OAMethod @endpoint, 'Append', @success OUT, '.amazonaws.com'
DECLARE @aws int
EXEC @hr = sp_OACreate 'Chilkat.AuthAws', @aws OUT
EXEC sp_OAMethod @credentials, 'StringOf', @sTmp0 OUT, 'access_key'
EXEC sp_OASetProperty @aws, 'AccessKey', @sTmp0
EXEC sp_OAMethod @credentials, 'StringOf', @sTmp0 OUT, 'secret_key'
EXEC sp_OASetProperty @aws, 'SecretKey', @sTmp0
EXEC sp_OASetProperty @aws, 'Region', @region
EXEC sp_OASetProperty @aws, 'ServiceName', 'sns'
EXEC sp_OASetProperty @aws, 'SignatureVersion', 4
DECLARE @rest int
EXEC @hr = sp_OACreate 'Chilkat.Rest', @rest OUT
EXEC sp_OASetProperty @rest, 'ConnectTimeoutMs', 20000
EXEC sp_OASetProperty @rest, 'IdleTimeoutMs', 60000
EXEC sp_OASetProperty @rest, 'VerboseLogging', 0
EXEC sp_OAMethod @rest, 'SetAuthAws', @success OUT, @aws
IF @success <> 1
BEGIN
PRINT 'Could not configure AWS signing.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
RETURN
END
EXEC sp_OAMethod @credentials, 'HasMember', @iTmp0 OUT, 'session_token'
IF @iTmp0 = 1
BEGIN
EXEC sp_OAMethod @credentials, 'StringOf', @sTmp0 OUT, 'session_token'
EXEC sp_OAMethod @stringCompare, 'SetString', @success OUT, @sTmp0
DECLARE @stringMatch3 int
EXEC sp_OAMethod @stringCompare, 'ContentsEqual', @stringMatch3 OUT, '', 1
EXEC sp_OAMethod @credentials, 'JsonTypeOf', @iTmp0 OUT, 'session_token'
IF (@iTmp0 <> 1) or (@stringMatch3 = 1)
BEGIN
PRINT 'session_token must be a nonempty string when supplied.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
RETURN
END
END
DECLARE @xml int
EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT
EXEC sp_OASetProperty @xml, 'Strict', 1
DECLARE @value nvarchar(4000)
-- Use an authorized recipient in E.164 format; this number is a placeholder.
DECLARE @phoneNumber nvarchar(4000)
SELECT @phoneNumber = '+15551234567'
DECLARE @phone int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @phone OUT
EXEC sp_OAMethod @phone, 'Append', @success OUT, @phoneNumber
EXEC sp_OAMethod @phone, 'GetRange', @sTmp0 OUT, 1, 1, 0
EXEC sp_OAMethod @stringCompare, 'SetString', @success OUT, @sTmp0
DECLARE @stringMatch4 int
EXEC sp_OAMethod @stringCompare, 'ContentsEqual', @stringMatch4 OUT, '0', 1
EXEC sp_OAMethod @phone, 'StartsWith', @iTmp0 OUT, '+', 1
EXEC sp_OAGetProperty @phone, 'Length', @iTmp1 OUT
EXEC sp_OAGetProperty @phone, 'Length', @iTmp2 OUT
IF (@iTmp0 <> 1) or (@iTmp1 < 2) or (@iTmp2 > 16) or (@stringMatch4 = 1)
BEGIN
PRINT 'Use E.164: + followed by at most 15 digits, starting with a nonzero digit.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
RETURN
END
DECLARE @digits int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @digits OUT
EXEC sp_OAMethod @digits, 'Append', @success OUT, '0123456789'
DECLARE @position int
SELECT @position = 1
EXEC sp_OAGetProperty @phone, 'Length', @iTmp0 OUT
WHILE (@position < @iTmp0)
BEGIN
EXEC sp_OAMethod @phone, 'GetRange', @sTmp0 OUT, @position, 1, 0
EXEC sp_OAMethod @digits, 'Contains', @iTmp0 OUT, @sTmp0, 1
IF @iTmp0 <> 1
BEGIN
PRINT 'Phone number must contain only + and digits.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
RETURN
END
SELECT @position = @position + 1
END
DECLARE @message int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @message OUT
EXEC sp_OAMethod @message, 'Append', @success OUT, 'This is a transactional test message from Amazon SNS.'
EXEC sp_OAGetProperty @message, 'Length', @iTmp0 OUT
EXEC sp_OAGetProperty @message, 'Length', @iTmp1 OUT
IF (@iTmp0 = 0) or (@iTmp1 > 1600)
BEGIN
PRINT 'Use a nonempty SMS message within the 1600-character Publish limit; AWS applies encoding and segmentation rules.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
RETURN
END
-- Explicit certificate verification; keep this Socket alive while Rest uses it.
DECLARE @connection int
EXEC @hr = sp_OACreate 'Chilkat.Socket', @connection OUT
EXEC sp_OASetProperty @connection, 'RequireSslCertVerify', 1
EXEC sp_OASetProperty @connection, 'MaxReadIdleMs', 60000
EXEC sp_OASetProperty @connection, 'MaxSendIdleMs', 60000
EXEC sp_OAMethod @endpoint, 'GetAsString', @sTmp0 OUT
EXEC sp_OAMethod @connection, 'Connect', @success OUT, @sTmp0, 443, 1, 20000
IF @success <> 1
BEGIN
PRINT 'TLS connection failed; inspect diagnostics privately.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @rest, 'UseConnection', @success OUT, @connection, 1
IF @success <> 1
BEGIN
PRINT 'Could not attach TLS connection.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @rest, 'ClearAllQueryParams', @success OUT
IF @success <> 1
BEGIN
PRINT 'Could not clear parameters from the previous request.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
-- Build a fresh form for each request; do not retain previous parameters.
-- AddQueryParam encodes raw values into the POST body. Do not pre-encode them.
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'Action', 'Publish'
IF @success <> 1
BEGIN
PRINT 'Could not set Action.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'Version', '2010-03-31'
IF @success <> 1
BEGIN
PRINT 'Could not set Version.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
-- Include temporary credentials in the signed form body on every request.
EXEC sp_OAMethod @credentials, 'HasMember', @iTmp0 OUT, 'session_token'
IF @iTmp0 = 1
BEGIN
EXEC sp_OAMethod @credentials, 'StringOf', @sTmp0 OUT, 'session_token'
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'X-Amz-Security-Token', @sTmp0
IF @success <> 1
BEGIN
PRINT 'Could not set X-Amz-Security-Token.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
END
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'PhoneNumber', @phoneNumber
IF @success <> 1
BEGIN
PRINT 'Could not set PhoneNumber.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @rest, 'AddQueryParamSb', @success OUT, 'Message', @message
IF @success <> 1
BEGIN
PRINT 'Could not set SMS message.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'MessageAttributes.entry.1.Name', 'AWS.SNS.SMS.SMSType'
IF @success <> 1
BEGIN
PRINT 'Could not set MessageAttributes.entry.1.Name.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'MessageAttributes.entry.1.Value.DataType', 'String'
IF @success <> 1
BEGIN
PRINT 'Could not set MessageAttributes.entry.1.Value.DataType.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @rest, 'AddQueryParam', @success OUT, 'MessageAttributes.entry.1.Value.StringValue', 'Transactional'
IF @success <> 1
BEGIN
PRINT 'Could not set MessageAttributes.entry.1.Value.StringValue.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
DECLARE @responseXml nvarchar(4000)
EXEC sp_OAMethod @rest, 'FullRequestFormUrlEncoded', @responseXml OUT, 'POST', '/'
EXEC sp_OAGetProperty @rest, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 <> 1
BEGIN
PRINT 'Request did not complete. Its outcome may be uncertain; reconcile before retrying.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @xml, 'LoadXml', @success OUT, @responseXml
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
IF @iTmp0 <> 200
BEGIN
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
PRINT 'SNS HTTP status: ' + @iTmp0
IF @success = 1
BEGIN
EXEC sp_OAMethod @xml, 'GetChildContent', @value OUT, 'Error|Code'
EXEC sp_OAGetProperty @xml, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 1
BEGIN
PRINT 'AWS error code: ' + @value
END
EXEC sp_OAMethod @xml, 'GetChildContent', @value OUT, 'RequestId'
EXEC sp_OAGetProperty @xml, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 1
BEGIN
PRINT 'AWS request ID: ' + @value
END
END
-- Full messages, headers, and signing diagnostics may contain private data.
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
IF @success <> 1
BEGIN
PRINT 'Expected a well-formed XML response.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAGetProperty @xml, 'Tag', @sTmp0 OUT
EXEC sp_OAMethod @stringCompare, 'SetString', @success OUT, @sTmp0
DECLARE @stringMatch5 int
EXEC sp_OAMethod @stringCompare, 'ContentsEqual', @stringMatch5 OUT, 'PublishResponse', 1
IF @stringMatch5 <> 1
BEGIN
PRINT 'Unexpected SNS response element.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
EXEC sp_OAMethod @xml, 'GetChildContent', @value OUT, 'ResponseMetadata|RequestId'
EXEC sp_OAMethod @stringCompare, 'SetString', @success OUT, @value
DECLARE @stringMatch6 int
EXEC sp_OAMethod @stringCompare, 'ContentsEqual', @stringMatch6 OUT, '', 1
EXEC sp_OAGetProperty @xml, 'LastMethodSuccess', @iTmp0 OUT
IF (@iTmp0 <> 1) or (@stringMatch6 = 1)
BEGIN
PRINT 'Missing or empty ResponseMetadata|RequestId.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
PRINT 'AWS request ID: ' + @value
EXEC sp_OAMethod @xml, 'GetChildContent', @value OUT, 'PublishResult|MessageId'
EXEC sp_OAMethod @stringCompare, 'SetString', @success OUT, @value
DECLARE @stringMatch7 int
EXEC sp_OAMethod @stringCompare, 'ContentsEqual', @stringMatch7 OUT, '', 1
EXEC sp_OAGetProperty @xml, 'LastMethodSuccess', @iTmp0 OUT
IF (@iTmp0 <> 1) or (@stringMatch7 = 1)
BEGIN
PRINT 'Missing or empty PublishResult|MessageId.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
RETURN
END
PRINT 'Message ID: ' + @value
PRINT 'SMS accepted by SNS; handset delivery is not confirmed.'
EXEC @hr = sp_OADestroy @stringCompare
EXEC @hr = sp_OADestroy @credentials
EXEC @hr = sp_OADestroy @endpoint
EXEC @hr = sp_OADestroy @aws
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @xml
EXEC @hr = sp_OADestroy @phone
EXEC @hr = sp_OADestroy @digits
EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @connection
END
GO