Issue while using local-name() XPATH in mountebank Xpath Selector

135 views
Skip to first unread message

vinitma...@gmail.com

unread,
May 29, 2018, 2:57:47 AM5/29/18
to mountebank-discuss
Hi All,

I am using the below mentioned request.

Request -

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<ns3:AcctInqRq xmlns:ns3="http://schema.cim.anz/AcctInq18">
<ANZTraceInfo>
<EffDt>2018-05-25</EffDt>
<InitDt>2018-05-25T14:13:19.625</InitDt>
<InitCompany>10</InitCompany>
<OperatorId>BDUAT01</OperatorId>
<BranchId>0</BranchId>
<TerminalId>PLBDWK09</TerminalId>
<OrigApp>PLB</OrigApp>
</ANZTraceInfo>
<RqUID>a7581168-06aa-4d16-a1ac-df1ecc6a86b4</RqUID>
<ANZAcctId>
<AcctId>368795841</AcctId>
<AcctType>ILS</AcctType>
</ANZAcctId>
<IncExtDetail>1</IncExtDetail>
<IncExtBal>1</IncExtBal>
<IncBal>1</IncBal>
<IncProductDetail>1</IncProductDetail>
<IncCardAcctDetail>1</IncCardAcctDetail>
<IncExtCardAcctDetail>1</IncExtCardAcctDetail>
</ns3:AcctInqRq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

In the Imposter when I am providing the xpath for selecting the root node - AcctInqRq

local-name(//*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='AcctInqRq'])

Getting the below mentioned Error :- It seems like Mountebank is not supporting local-name() outside the xpath mentioned.

warn: [mb:2525] error creating imposter: [{"code":"bad data","message":"malformed stub request","data":"result.map is not a function",

Predicate i am using is mentioned below :-

"predicates": [{
"equals": {
"body": "AcctInqRq"
},
"xpath":{
"selector":"local-name(//*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='AcctInqRq'])"
}

}]

If we apply the Xpath on the request for testing, we can see we get the value as AcctInqRq but its not working in mountebank.

How to solve this issue?

Brandon Byars

unread,
May 31, 2018, 2:57:30 PM5/31/18
to vinitma...@gmail.com, mountebank-discuss
Hi there,
I'm not enough of an XPath expert to know if your selector is valid or not--I've never used local-name before. That said, I believe there's a much easier selector that will work:

/s:Envelope/s:Body/t:acctInqRq

and you'd have to pass the namespace map in the "ns" field:

"xpath": {
  "selector": "/s:Envelope/s:Body/t:acctInqRq",
  "ns": {
  }
}

That said, the acctInqRq node isn't a scalar value--it's an entire XML sub-document. To get anything meaningful for the predicate, you'd have to navigate down to the scalar value you want, like, say, an OperatorID of "BDUAT01". And if you do that and don't care too much about testing the SOAP nesting structure, you can simplify your XPath even more to "//OperatorID"

Hope that helps
-Brandon



--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages