Iterating and Parsing SOAP Response Elements

MarkB1
Kilo Contributor

I am trying to parse through a SOAP response from an outbound web service.  As such, since I am operating from a scoped application, I am unable to return a nodelist of elements.  My goal is to grab the PIID and modNumber from the soap response below:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Body>
		<getListResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
			<getListAwardResponse>
				<listOfAwardSummaries>
					<awardSummary>
						<awardID>
							<awardContractID>
								<agencyID>1111</agencyID>
								<PIID>987AND623</PIID>
								<modNumber>0</modNumber>
								<transactionNumber>0</transactionNumber>
							</awardContractID>
							<referencedIDVID>
								<agencyID>1111</agencyID>
								<PIID>432A</PIID>
								<modNumber>0</modNumber>
							</referencedIDVID>
						</awardID>
					</awardSummary>
					<awardSummary>
						<awardID>
							<awardContractID>
								<agencyID>1620</agencyID>
								<PIID>987ABC992</PIID>
								<modNumber>0</modNumber>
								<transactionNumber>0</transactionNumber>
							</awardContractID>
							<referencedIDVID>
								<agencyID>1620</agencyID>
								<PIID>964Z</PIID>
								<modNumber>0</modNumber>
							</referencedIDVID>
						</awardID>
					</awardSummary>
				</listOfAwardSummaries>
			</getListAwardResponse>
		</getListResponse>
	</soapenv:Body>
</soapenv:Envelope>
4 REPLIES 4

Abhinay Erra
Giga Sage

There is an api for scoped app, look at XMLDocument2

MarkB1
Kilo Contributor

I am aware XMLDocument2.  However, it is a scaled down version of XMLDocument that allows for returning all the 'awardSummary' nodes in the example above.  My expected response could have one to many 'awardSummary' nodes.  In other words how to I get a list of nodes with the same element tag name?

MarkB1
Kilo Contributor

I need to grab all the 'awardSummary' nodes, reading out the PIID and the modNumber.

Nia McCash
Mega Sage
Mega Sage

The code in this thread seems to work for me so far: https://community.servicenow.com/community?id=community_question&sys_id=ea36c7a1db1cdbc01dcaf3231f96...  I'm not using it in a scoped app though.