[醒目]高分求助:Run-time error '91' Object variable or With block variable not set
在VB中用MSXML2.XMLHTTP发送一个SOAP消息,
出现如下错误:Run-time error '91'
Object variable or With block variable not set
如何解决?
代码如下,最后一句出错
Dim h2 As MSXML2.XMLHTTP
'初始化http对象
Set h2 = New MSXML2.XMLHTTP
'向指定的URL发送Post消息
h2.open "POST", strHttp, False
h2.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
h2.setRequestHeader "HOST", strHostIP
h2.setRequestHeader "Content-Length", Len(strXML)
'一定要与WEBSERVICE的命名空间相同,否则服务会拒绝
h2.setRequestHeader "SOAPAction", "http://tempuri.org/" & strElenment
h2.send (strXML)