SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#1 22-11-2018 07:04:42

SeanR
Administrator
Registered: 20-11-2018
Posts: 148

Extracting information from Elements returned by a Web Service Call

Goodday

Can I please ask your assist with an xpath to collect a ticket number written in memory from as a response.

Attached is an XPress document from a json string written to memory and our field of interest is the "display_value" tag

I am not sure how to pick that value.

Please assist

XPress doc

<?xml version="1.0" encoding="iso-8859-1"?>
<XServiceBroker xmlns="http://www.sxi.co.za/XMLSchema">
	<XHeader>
		<XPress>
			<Destination>127.0.0.1</Destination>
		</XPress>
		<XServiceBroker>
			<ActionName>Create</ActionName>
			<Provider>AddtoExist</Provider>
		</XServiceBroker>
	</XHeader>
	<ResponseMessage>
		<Object xmlns="">
			<import_set type="string">ISET0013048</import_set>
			<result class="array">
			<Element class="object">
			<display_name type="string">number</display_name>
			<display_value type="string">INC0068191</display_value>
			<record_link type="string">https://south32uat.service-now.com/api/now/table/incident/a949c7f1db716240ca53f1fabf961943</record_link>
			<status type="string">inserted</status>
			<sys_id type="string">a949c7f1db716240ca53f1fabf961943</sys_id>
			<table type="string">incident</table>
			<transform_map type="string">Event Management Incident</transform_map>
			</Element>
			</result>
			<staging_table type="string">u_event_mgmt</staging_table>
		</Object>
	</ResponseMessage>
</XServiceBroker>

Offline

#2 22-11-2018 08:16:33

SeanR
Administrator
Registered: 20-11-2018
Posts: 148

Re: Extracting information from Elements returned by a Web Service Call

The XML here is returned as a response to a Web Service call.

So the issue here is not an incorrect Xpath but rather the fact that you are trying to address an element which has not been loaded into memory.

To call a Web Service with X-ServiceBroker a "Create" mapping is used, as one needs to send information to the Web Service. This create is usually done with the aid of a stylesheet to construct the correct payload needed by the Web Service being consumed. The response returned by the Web Service is not automatically loaded into memory as it would have been had a Collect mapping being run.

Because of this, IMMEDIATELY following the Create mapping used to call the Web Service, one needs to call a Data Definition to extract the information elements from the response, this is typically done with a MemoryDataManipultion mapping. In the said DataDefinition the element can successfully be addressed with an XPath statement.

Offline

Board footer

Powered by FluxBB