VB调用WebService(SOA2.0接口)(直接Post方式)并解析返回的XML

时间:2022-11-04 06:15:26
  SOA 2.0接口
Function GetDepartmentCode(reqDeptCode)
Dim soaRequestXML : soaRequestXML = ""
Dim strCustomerSOAServer : strCustomerSOAServer = "www.td.com" soaRequestXML ="<?xml version=""1.0"" encoding=""utf-8""?>"
soaRequestXML = soaRequestXML & "<GetDepartmentCodeRequest xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.td.com/platform/CTI/BaseWsCore/v1"">"
soaRequestXML = soaRequestXML & "<DepartmentCode xmlns="""">"&reqDeptCode&"</DepartmentCode>"
soaRequestXML = soaRequestXML & "<Regions xmlns="""">H</Regions>"
soaRequestXML = soaRequestXML & "</GetDepartmentCodeRequest>" dim url
url="http://"&strCustomerSOAServer&"/td-core/api/GetDepartmentCode.xml"
dim xmlHttp
Set xmlHttp = CreateObject("Microsoft.XMLHTTP")
xmlHttp.open "POST", url, False
xmlHttp.setRequestHeader "Content-Type", "application/xml;"
xmlHttp.send (soaRequestXML)
While xmlHttp.readyState <>
Wend GetDepartmentCode = xmlHttp.responseText End Function
 调用上面接口方法 并解析返回的xml数据
Sub ShowVdnSelect(strRouteDest)
dim strVdnCode, strVdnName, strSelected, soapXml
set soapXml = Server.CreateObject("microsoft.xmldom")
soapXml.async=false
soapXml.setProperty "SelectionLanguage","XPath" soapXml.loadXML(GetDepartmentCode("yiget")) Response.Write "<select name='VDN_List' id='VDN_List'>"
Response.Write "<option value=''>请选择一个服务组</option>" for each tempNode in soapXml.SelectNodes("//Vdn")
strVdnCode = tempNode.SelectSingleNode("VdnCode").text
strVdnName = tempNode.SelectSingleNode("VdnName").text if instr(AllowVDNList, ","& strVdnCode &",") then
if strRouteDest=strVdnCode then
strSelected=" selected"
else
strSelected=""
end if if left(strVdnName,)<>"公共组" then
Response.Write "<option value='" & strVdnCode & "'" & strSelected & ">" & strVdnCode & " " & strVdnName & "</option>"
end if
end if
'end if
next Response.Write "</select>"
End Sub