2012-02-13 50 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