AutoIT脚本/ UDF与Amazon S3 API连接

时间:2012-02-13 07:42:41

标签: amazon-s3 autoit

我正在尝试使用Amazon S3 API创建AutoIT脚本界面。我一直在尝试SOAP和REST,虽然没有成功。

这是我正在使用的SOAP代码(在AutoIT论坛上来自Ptrex的修改示例),但是我得到以下响应: “soapenv:Client.badRequest缺少SOAPAction标头”

老实说,代码对我来说没那么有意义,我真的只是在摆弄。

非常感谢任何有关如何正确连接Amazon S3 API的正确方向的示例或指示!

; Initialize COM error handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$objHTTP = ObjCreate("Microsoft.XMLHTTP")
$objReturn = ObjCreate("Msxml2.DOMDocument.3.0")

$strEnvelope = '<soap:envelope xmlns:soap="urn:schemas-xmlsoap-org:soap.v1">' & _
'<soap:header></soap:header>' & _
'<soap:body>' & _
'<ListAllMyBuckets xmlns="http://doc.s3.amazonaws.com/2006-03-01">' & _
  '<AWSAccessKeyId>MYACCESSKEYID</AWSAccessKeyId>' & _
  '<Timestamp>2006-03-01T12:00:00.183Z</Timestamp>' & _
  '<Signature>MYSECRETSIGNATURE</Signature>' & _
'</ListAllMyBuckets>' & _
'</soap:body>' & _
'</soap:envelope>'

; Set up to post to our local server
$objHTTP.open ("post", "https://s3.amazonaws.com/soap", False)

; Set a standard SOAP/ XML header for the content-type
$objHTTP.setRequestHeader ("xmlns:aws",  "http://security.amazonaws.com/doc/2007-01-01/")

 Make the SOAP call
$objHTTP.send ($strEnvelope)

; Get the return envelope
$strReturn = $objHTTP.responseText

; ConsoleWrite("Debug : "& $strReturn & @CR & @CR)

; Load the return envelope into a DOM
$objReturn.loadXML ($strReturn)

ConsoleWrite("Return of the SOAP Msg : " & @CR & $objReturn.XML & @CR & @CR)

; Query the return envelope
$strQuery = "SOAP:Envelope/SOAP:Body/ListAllMyBuckets"

$dblTax = $objReturn.selectSingleNode($strQuery)
$Soap = $objReturn.Text

MsgBox(0,"SOAP Response",$Soap)

1 个答案:

答案 0 :(得分:0)

我不知道这是否会帮助你,但是从自动部分一切运行良好你从亚马逊获得的答案'soapenv:Client.badRequest缺少SOAPAction标题'意味着它实际上说的是你的请求。 -namely:缺少SOAPAction标头

你得到的确是一个响应,但来自服务器的错误响应。我建议尝试重写请求

我在这里找到了最相关的描述:http://docs.aws.amazon.com/AWSSimpleQueueService/2008-01-01/SQSDeveloperGuide/index.html?MakingRequests_MakingSOAPRequestsArticle.html