panza
panza

Reputation: 1431

XQuery assertion failure for SOAP UI

I have been following this example:

https://bharathsharesinfo.wordpress.com/2013/03/16/assertions-xquery-match/

I have imported the wsdl file as per:

http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl

I have generated a MockService for the response and added a test case for the operation GetStockQuote. I have then added the XQuery Match assertion as follows (the declarations were added automatically):

declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://www.restfulwebservices.net/DataContracts/2008/01';
declare namespace ns='http://www.restfulwebservices.net/ServiceContracts/2008/01';
    <Result>
    {
    for $x in //ns1:GetStockQuoteResult[1]
    return <Symbol>{data($x/a:Symbol/text())}</Symbol>
    }
    </Result>

I am returned with the following error:

XQuery Match Assertion failed for path [declare namespace ns1='http://www.restfulwebservices.net/DataContracts/2008/01'; declare namespace ns='http://www.restfulwebservices.net/ServiceContracts/2008/01';   { for $x in //ns1:GetStockQuoteResult[1] return  {data($x/a:Symbol/text())}  }  ] : RuntimeException:java.lang.reflect.InvocationTargetException

Can you help?

Upvotes: 0

Views: 865

Answers (2)

albciff
albciff

Reputation: 18507

As @wst correctly answer the a namespace prefix is missing; if you see the SOAPUI error log you will see:

  XPST0081: XQuery static error in #...<Symbol>{data($x/a:Symbol/text#:
    Prefix a has not been declared

Of course a solution is to simple declare the namespace a in your XQuery but there is another option; in SOAPUI you can use * wildcard to reference any namespace, so your XQuery Assertion could be simplified to:

<Result>
{
for $x in //*:GetStockQuoteResult[1]
return <Symbol>{data($x/*:Symbol/text())}</Symbol>
}
</Result>

Upvotes: 1

wst
wst

Reputation: 11771

In your XPath, you reference a:Symbol, but the namespace prefix a is not declared and assigned to a namespace.

Upvotes: 0

Related Questions