0
votes

I am using Xpath Extractor to find out a node value from a XML response but Jmeter is throwing an error every time I execute with the following error:

jmeter.extractor.XPathExtractor: TransformerException while processing ((//*[local-name() = 'RequestID'])[2]/text()) -1

The xpath expression used in Jmeter: (//*[local-name() = 'RequestID'])[2]/text()

I checked my xpath expression online and its valid and returning the expected value. Not sure what is the problem with jmeter.

Here is the xml:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<urn1:ServiceControl xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">
<urn1:EmergencyRequestIndicator>true</urn1:EmergencyRequestIndicator>
<urn1:VersionID>1.0</urn1:VersionID>
<urn1:LanguageCode type="Advisor">en-US</urn1:LanguageCode>
<urn1:LanguageCode type="Subscriber">en-US</urn1:LanguageCode>
<urn1:ApplicationID>GAA</urn1:ApplicationID>
<urn1:LogicalID>W2DZD0Y06</urn1:LogicalID>
<urn1:ComponentID>GAA-ocsComponent</urn1:ComponentID>
<urn1:ReferenceID>CorrelationId</urn1:ReferenceID>
<urn1:SentTimeStamp>2010-04-23T14:27:10Z</urn1:SentTimeStamp>
<urn1:MessageType>ocsMessageType</urn1:MessageType>
<urn1:ChannelID>GAA</urn1:ChannelID>
<urn1:TaskID>ocsTask</urn1:TaskID>
<urn1:Environment>4.0</urn1:Environment>
<urn1:BODID>GAA-CorrelationId</urn1:BODID>
<urn1:Asynchronous>
<urn1:TimeToLive xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">10</urn1:TimeToLive>
<urn1:PassThroughData xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">
<urn1:Key xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">1</urn1:Key>
<urn1:Value xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">10</urn1:Value>
</urn1:PassThroughData>
<urn1:ExpectedResponseTime xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">30</urn1:ExpectedResponseTime>
<urn1:RequestID xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">100</urn1:RequestID>
<urn1:RetryStrategy xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">
<urn1:Name xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">RetryName</urn1:Name>
<urn1:LongTermRetryIndicator xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">false</urn1:LongTermRetryIndicator>
<urn1:ResponseRequiredOnErrorPoolMoveIndicator xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">true</urn1:ResponseRequiredOnErrorPoolMoveIndicator>
</urn1:RetryStrategy>
<urn1:ReplyRequiredIndicator xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">true</urn1:ReplyRequiredIndicator>
<urn1:ReplyToMessageID xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">1000</urn1:ReplyToMessageID>
<urn1:CallbackURI xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">urn1:www:com</urn1:CallbackURI>
<urn1:FaultURI xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">urn1:www:com</urn1:FaultURI>
<urn1:ProcessingModes xmlns:urn1="urn:com:sample:global:common:schema:ServiceControl:2">ProcessingMode</urn1:ProcessingModes>
</urn1:Asynchronous>
<urn1:Synchronous/>
</urn1:ServiceControl>
</S:Header>
<S:Body>
<ns2:ServiceRequestReference xmlns="urn:com:sample:ocs:common:schema:AutoTask:11" xmlns:ns10="urn:com:sample:global:common:schema:CallContext:2" xmlns:ns11="urn:com:sample:ocs:common:schema:ServiceFault:11" xmlns:ns12="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns13="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns14="http://www.w3.org/2000/09/xmldsig#" xmlns:ns15="urn:com:sample:global:common:schema:ServiceControl:2" xmlns:ns2="urn:com:sample:ocs:common:schema:CommonTypes:11" xmlns:ns3="urn:com:sample:ocs:common:schema:AutoInformation:11" xmlns:ns4="urn:com:sample:ocs:common:schema:UnitConfiguration:11" xmlns:ns5="urn:com:sample:ocs:common:schema:SubscriberRequest:11" xmlns:ns6="urn:com:sample:ocs:common:schema:ElectricAuto:11" xmlns:ns7="urn:com:sample:ocs:common:schema:EmergencyRequest:11" xmlns:ns8="urn:com:sample:ocs:common:schema:AutoRequest:11" xmlns:ns9="urn:com:sample:ocs:common:schema:AutoConnection:11">
<ns2:RequestID>2648331</ns2:RequestID>
<ns2:isProcessingAnotherRequest>false</ns2:isProcessingAnotherRequest>
<ns2:estimatedProcessingTime>0</ns2:estimatedProcessingTime>
</ns2:ServiceRequestReference>
</S:Body>
</S:Envelope>
1
I don't know the environment you're describing, but I believe local-name is an xpath 2.0 function, so I would check if this product supports xpath 2.0 and not just xpath 1.0 - TGH

1 Answers

0
votes

You can subtract 1 from variable using i.e. Beanshell Post Processor

Assuming that you use RequestID as a reference name in XPath Extractor and following XPath is being used to get RequestID

(//*[local-name() = 'RequestID'])[2]/text()

or //ns2:RequestID/text()

Next Beanshell code will allow you to manipulate the variable

int requestId = Integer.parseInt(vars.get("RequestID"));
requestId = requestId--;
vars.put("RequestID", String.valueOf(requestId));