I have returned a response from SOAP web services using VBA code. I want to obtain the node values from the response. I have looked across forums for examples but none appear to do exactly what I want. The closest thread which is similar to my situation is the one below:
VBA Excel Macro SelectSingleNode returns nothing
Any examples or assistance on how to get started would be appreciated.
Sample XML Request in VBA:
'Set Reference to Microsoft XML, v6.0
Option Explicit
Dim responseText As String
Dim sURL As String
Dim sEnv As String
Dim xmlhtp As New MSXML2.XMLHTTP
Dim xmlDoc As New DOMDocument
Dim webserviceSOAPActionNameSpace
Sub test()
sURL = "http://soap.qacomplete.smartbear.com/psWS.asmx?wsdl"
sEnv = "<?xml version =""1.0"" encoding=""utf-8""?>"
sEnv = sEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
sEnv = sEnv & "<soap:Body>"
sEnv = sEnv & "<Bugs_LoadByCriteria xmlns=""http://www.pragmaticsw.com/"">"
sEnv = sEnv & "<AuthenticationData>"
sEnv = sEnv & "<AppCode>agSP</AppCode>"
sEnv = sEnv & "<DeptId>81842</DeptId>"
sEnv = sEnv & "<ProjId>92553</ProjId>"
sEnv = sEnv & "<UserId>147280</UserId>"
sEnv = sEnv & "<PassCode>Password1</PassCode>"
sEnv = sEnv & "</AuthenticationData>"
sEnv = sEnv & "<Condition><![CDATA[<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
sEnv = sEnv & " xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opEQU'>"
sEnv = sEnv & "<Items Type='tField'>"
sEnv = sEnv & "<Value xsi:type='xsd:string'>Custom11</Value>"
sEnv = sEnv & "</Items>"
sEnv = sEnv & "<Items Type='tString'>"
sEnv = sEnv & "<Value xsi:type='xsd:string'>Finance</Value>"
sEnv = sEnv & "</Items>"
sEnv = sEnv & "</Conditions>]]>"
sEnv = sEnv & "</Condition>"
sEnv = sEnv & "</Bugs_LoadByCriteria>"
sEnv = sEnv & "</soap:Body>"
sEnv = sEnv & "</soap:Envelope>"
With xmlhtp
webserviceSOAPActionNameSpace = "http://www.pragmaticsw.com/"
.Open "POST", sURL, False
.setRequestHeader "POST", "http://soap.qacomplete.smartbear.com/psWS.asmx HTTP/1.1"
.setRequestHeader "Content-Type", "application/soap+xml; charset=UTF-8"
.setRequestHeader "SOAPAction", webserviceSOAPActionNameSpace & "Bugs_LoadByCriteria"
.setRequestHeader "Accept-encoding", "zip"
.send sEnv
xmlDoc.LoadXML .responseText
End With
End Sub
Sample Response XML:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Bugs_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
<Bugs_LoadByCriteriaResult>
<Bug>
<CustomFieldNames>
<BugId>3253017</BugId>
<Title>DM78 Customer and DM25 Vendor Master Data - default criteria</Title>
<StatusCode>Closed</StatusCode>
<SeverityCode>Minor</SeverityCode>
<PriorityCode>P3</PriorityCode>
<IssueCode>Data</IssueCode>
<ResolutionCode>Fixed</ResolutionCode>
<AssigneeUserId>137784</AssigneeUserId>
<OpenedBy>136840</OpenedBy>
<ClosedBy>137748</ClosedBy>
<ResolvedBy>137748</ResolvedBy>
</Bug>
</Bugs_LoadByCriteriaResult>
</Bugs_LoadByCriteriaResponse>
</soap:Body>
</soap:Envelope>