我正在尝试从Excel VBA进行SOAP调用。它按预期工作。我从服务器收到SOAP响应。但是我有两个问题:
关于#1,这是我读的书-https://developer.cisco.com/docs/axl/#!12-0-axl-developer-guide/using-jsessionidsso-to-improve-performance
听起来不错。但是,我怎么知道我在请求标头中设置的cookie确实有效?我在代码中对其进行了测试,无论是否设置cookie,它似乎都没有影响。
关于#2,如果客户端不信任服务器证书,则HTTPS将失败。是否要让VBA忽略证书警告并建立连接?
感谢您的帮助!
我的代码如下:
Sub getUser()
'Set and instantiate our working objects
Dim sEnv, sURL, sUsername, sPassword, sUserID, sIsLDAP As String
Dim Req As Object
Dim Resp As New MSXML2.DOMDocument60
Dim r As Long
Set Req = CreateObject("MSXML2.SERVERXMLHTTP")
Set Resp = CreateObject("MSXML2.DOMDocument.6.0")
sURL = "https://cm.example.local:8443/axl"
sUsername = "admin"
sPassword = "Pass123"
sUserID = "jdoe"
' Open initial connection to AXL service
Req.Open "Post", sURL, False, sUsername, sPassword
' Create SOAP envelelope with search criteria
sEnv = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ns=""http://www.cisco.com/AXL/API/11.5"">" & _
"<soapenv:Header/>" & _
"<soapenv:Body>" & _
" <ns:getUser>" & _
" <userid>" & sUserID & "</userid>" & _
" <returnedTags>" & _
" <ldapDirectoryName>?</ldapDirectoryName>" & _
" </returnedTags>" & _
" </ns:getUser>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"
' Send SOAP Request
Req.send (sEnv)
debug.print Req.ResponseText
End