Hi All,
OpenEdge 11.0
Has anyone managed to connect their OpenEdge application to AWS SQS?
If so, how did you manage the sign the HTTP request correctly?
I (believe I) am following the instructions as per "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QueryAuth.html" to sign the http request correctly using my AWS Key and Secret code.
Point 1 - I have manually built this
Point 2 - again manually built this
Point 3 - I am using MESSAGE-DIGEST function using "SHA-256" as the hash algorithm.
Point 4 - I'm using the BASE64-ENCODE function.
However I'm getting the below error response and cannot seem to get passed it. I *believe* I have followed the instructions correctly.
snip..
<Type>Sender</Type>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message>
Help?
Thanks
David
What platform are you running on ?
Sorry,missed that piece of info.
Windows 7, 64bit.
Then you may want to look at http://www.nsoftware.com/ibiz/amazon/
Sorry, also meant to ask, are you trying to write this in ABL ?
Thanks re: previous post. I'll take a look at that site.
Yes re: *trying* to writing in ABL :-).
This is just a POC for my own personal benefit and as an experiment/learning on AWS SQS.
how are you url encoding the final signature ?
"The final signature you send in the request must be URL encoded as
specified in RFC 3986 (for more information, go to
http://www.ietf.org/rfc/rfc3986.txt). If your toolkit URL encodes your
final request, then it handles the required URL encoding of the
signature. If your toolkit doesn't URL encode the final request, then
make sure to URL encode the signature before you include it in the
request. Most importantly, make sure the signature is URL encoded only
once. A common mistake is to URL encode it manually during signature
formation, and then again when the toolkit URL encodes the entire
request."
I would download the free aws .net sdk (http://aws.amazon.com/sdkfornet/) which has .net controls to do what you want:
for example [pseudo-code]
using Amazon.*.
using Amazon.SQS.*.
using Amazon.SQS.Model.*.
def var sqs as AmazonSQS no-undo.
sqs = AWSClientFactory.CreateAmazonSQSClient(awsAccessKey, awsSecretAccessKey)
would seem to take all of the pain out of your hashing problems ..
I grabbed a copy of the url-encode function from web/method/cgi-utils.i.
I made some mods to make it work for RFC 3986 (as comments in the function was using RFC 1738).
NIIIIIIICCCCCEEEEE!
I do keep forgetting about OE .NET Controls, having worked on OE/Unix for over 10 years!
And since you are on OE11 the Windows AppServer, WebSpeed and TTY client processes can use .NET as well.
MUCH EASIER!
Although I would still like to find out why my original design didn't work.
USING Amazon.*.
USING Amazon.SQS.*.
USING Amazon.SQS.Model.*.
USING Amazon.SQS.Util.*.
CREATE WIDGET-POOL.
{SQS/awskeys.i}
DEF VAR sqs AS CLASS AmazonSQSClient NO-UNDO.
DEF VAR rqst AS CLASS SendMessageRequest NO-UNDO.
DEF VAR resp AS CLASS SendMessageResponse NO-UNDO.
DEF VAR awsKey AS CHAR NO-UNDO.
DEF VAR awsSecret AS CHAR NO-UNDO.
DEF VAR awsQueue AS CHAR NO-UNDO.
DEF VAR i AS INT NO-UNDO.
ASSIGN
awsKey = getAWSAccessKeyId()
awsSecret = getAWSSecretAccessKey()
awsQueue = getAWSQueueName()
.
DO ON ERROR UNDO, LEAVE:
sqs = NEW AmazonSQSClient(awsKey, awsSecret).
rqst = NEW SendMessageRequest().
DO i = 1 TO 10:
rqst:WithMessageBody("Test" + STRING(i)).
rqst:WithQueueUrl(awsQueue).
resp = sqs:SendMessage(rqst).
/*MESSAGE resp:ResponseMetadata SKIP resp:SendMessageResult*/
/*VIEW-AS ALERT-BOX. */
END.
END.
DELETE OBJECT rqst.
DELETE OBJECT resp.
sqs:Dispose().
DELETE OBJECT sqs.
DELETE WIDGET-POOL.
Thanks Julian for your help. Much Appreciated!
dmci2309 schrieb:
MUCH EASIER!
Although I would still like to find out why my original design didn't work.
USING Amazon.*.
USING Amazon.SQS.*.
USING Amazon.SQS.Model.*.
USING Amazon.SQS.Util.*.CREATE WIDGET-POOL.
Thanks for sharing the code :-)
Just a few remarks on the code: The CREATE and DELETE WIDGET-POOL statement are not needed. They don't do anything for .NET, there a more sophisticated GC algorithm in the ABL.
With those USING statements, get into a habbit of adding the FROM ASSEMBLY option. That will speed up compilation, when you have network folders in you propath.
no problem, and as Mike says, thanks for sharing the code.
Good luck !
Thanks for the advice Mike.
I do still need to read through all the OE .NET documentation. I only read enough to get access to the libraries themselves.
np with the code sharing, its only a simple POC. (not enough samples around IMO).
Yes, that's true.
Some examples are here: http://blog.consultingwerk.de/consultingwerkblog/2012/04/extreme-windows-desktop-integration-–-updated/