对于我正在从事的项目,我正在尝试进行异步 XMLHTTP 调用。我正在使用以下代码:
soapmessage = _
"<?xml version='1.0' encoding='utf-8'?>"& vbcrlf& vbcrlf & _
"<soap:Envelope"& vbcrlf & _
" xmlns:xsi="&chr(34)&"http://www.w3.org/2001/XMLSchema-instance"&chr(34)&
vbcrlf & _
" xmlns:xsd="&chr(34)&"http://www.w3.org/2001/XMLSchema"&chr(34)& vbcrlf & _
" xmlns:soap="&chr(34)&"http://www.w3.org/2003/05/soap-
envelope"&chr(34)&">"& vbcrlf & _
" <soap:Body>"& vbcrlf & _
"<notification>"& vbcrlf & _
" <action>Action</action>"& vbcrlf & _
" <objectid>333333</objectid>"& vbcrlf & _
"</notification>"& vbcrlf & _
" </soap:Body>" & vbcrlf & _
" </soap:Envelope>"
strEndpoint = "**********"
Set xmlhttp = CreateObject("MSXML2.SERVERXMLHTTP.6.0")
xmlhttp.open "POST", strEndpoint, True
xmlhttp.OnReadyStateChange = doHttpOnReadyStateChange()
xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
xmlhttp.Send soapmessage
Function doHttpOnReadyStateChange()
If xmlhttp.ReadyState = 4 Then
'do something
End If
End Function
当我尝试执行此操作时,我得到以下信息:
test.vbs(19, 1) Microsoft VBScript 运行时错误:类型不匹配:'xmlhttp.OnReadyStateChange'
知道我做错了什么吗?这是我第一次尝试异步调用,所以我对 OnReadyStateChange 有点困惑