需要访问公司的FlexFlow,接口是WebService,用的是AutoIt,其实最主要用到一个组件"Microsoft.XMLHTTP",代码如下:
(刚开始用的是Dll Call的方式,但是里面隐藏用到一个窗体句柄,所以AutoIt就无法直接用了)
因为HTML实体字符的原因,有部分代码可能无法正常显示,可以下载附件查看
Dim $objHTTP
Dim $strEnvelope
Dim $strReturn
Dim $objReturn
Dim $dblTax
Dim $strQuery
Dim $value
;$value = InputBox("Testing", "Enter your new value here.", 10)
; Initialize COM error handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$objHTTP = ObjCreate("Microsoft.XMLHTTP")
$objReturn = ObjCreate("Msxml2.DOMdocument.3.0")
; Create the SOAP Envelope
$sRequest = '<?xml version="1.0" ?><GetUnitInfo xmlns="urn:GetUnitInfo-schema" SerialNumber="0T1AWS99608" />'
;'<strRequest><?xml version="1.0" ?><GetUnitInfo xmlns="urn:GetUnitInfo-schema" SerialNumber="0T1AWS996082" /></strRequest>' & _
$strEnvelope = '<?xml version="1.0" encoding="utf-8"?>' & _
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' & _
"<soap:Body>" & _
'<GetUnitInfo xmlns="http://www.flextronics.com/FFTesterWS/">' & _
"<strRequest>"&$sRequest&"</strRequest>" & _
"<strUnitInfo>"&""&"</strUnitInfo>" & _
"<strStationName>"&"AutoTest_ForTesting"&"</strStationName>" & _
"<strUserID>"&""&"</strUserID>" & _
"</GetUnitInfo>" & _
"</soap:Body>" & _
"</soap:Envelope>"
; Set up to post to our local server
$objHTTP.open ("post", "http://10.201.152.16/FFTesterWSPMC/FFTesterWS.asmx", False)
; Set a standard SOAP/ XML header for the content-type
$objHTTP.setRequestHeader ("Content-Type", "text/xml")
; Set a header for the method to be called
$objHTTP.setRequestHeader ("SOAPAction", "http://www.flextronics.com/FFTesterWS/GetUnitInfo")
ConsoleWrite("Content of the Soap envelope : "& @CR & $strEnvelope & @CR & @CR)
; 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)
; Query the return envelope
$strQuery = "/soap:Envelope/soap:Body/GetUnitInfoResponse/GetUnitInfoResult"
$iResult = $objReturn.selectSingleNode($strQuery)
$Soap = $iResult.Text
ConsoleWrite("iResult : " & @CR & $Soap & @CR & @CR)
MsgBox(0,"Return", $Soap)
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8)
Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & $HexNumber & @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext _
)
SetError(1) ; to check for after this function returns
Endfunc