如何为webservice调用设置SOAP标头

时间:2017-01-17 07:38:23

标签: web-services soap vbscript

我使用以下脚本从基本的经过身份验证的SOAP Web服务获取响应。下面的代码将凭据放在HTTP标头中,因此我没有得到响应。

如何使用VBScript更新SOAP标头中的凭据?

我的代码:

Set objHTTP = CreateObject("Msxml2.ServerXMLHTTP")

objHTTP.setOption 2, 13056

strTextContent = Trim("Content of my request xml")

strUserName = "mylogin"
strPassword = "mypassword"

strURL = "myendpoint"

objHTTP.Open "GET", strURL, False, strUserName, strPassword
objHTTP.setRequestHeader "Authorization", "Basic " & Base64Encode(strUserName & ":" & strPassword)
objHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objHTTP.setRequestHeader "SOAPAction", "mysoapaction"

objHTTP.send strTextContent

strResponseReceived = objHTTP.responseText
MsgBox strResponseReceived

0 个答案:

没有答案