AutoIt访问WebService

需要访问公司的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>&lt;?xml version="1.0" ?&gt;&lt;GetUnitInfo xmlns="urn:GetUnitInfo-schema" SerialNumber="0T1AWS996082" /&gt;</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

soap.au3

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值