2012-02-13 100 views
1

我正在尝试使用Amazon S3 API制作AutoIT脚本界面。我一直在尝试SOAP和REST,尽管没有成功。AutoIT脚本/ UDF与Amazon S3 API接口

这是SOAP代码我与(从Ptrex在AutoIt的论坛变形例)的工作,但我得到如下回应: “soapenv:Client.badRequest缺少SOAPAction头”

说实话,代码对我来说并没有多大意义,我真的只是在修补。

任何例子或指针,让我正确的方向在如何正确地与亚马逊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) 

回答

0

我不知道这是否可以帮助你但从AutoIt的部分一切正常,你从亚马逊获得答案“soapenv:Client.badRequest缺少SOAPAction头”的意思,它实际上说的东西拨错的请求。 - 名称:缺少SOAPAction标头

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

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