Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error getting a node on SOAP UI's test case XPATH

I had been stuck while playing with the SOAP UI getting started tutorial because i can't produce an assertion condition for a simple testing. I'm Using the XPATH method to test the following SOAP message:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/">
         <GetCityWeatherByZIPResult>
            <Success>false</Success>
            <ResponseText>City could not be found in our weather data. Please contact CDYNE for more Details.</ResponseText>
            <State/>
            <City/>
            <WeatherStationCity/>
            <WeatherID>-1</WeatherID>
            <Description/>
            <Temperature/>
            <RelativeHumidity/>
            <Wind/>
            <Pressure/>
            <Visibility/>
            <WindChill/>
            <Remarks/>
         </GetCityWeatherByZIPResult>
      </GetCityWeatherByZIPResponse>
   </soap:Body>
</soap:Envelope> 

I'm using the following Xpath expression:

declare namespace i='http://www.w3.org/2001/XMLSchema-instance';
//i:GetCityWeatherByZIPResult[1]/i:Success[1]

and this is the error:

XPathContains assertion failed for path [declare namespace i='http://www.w3.org/2001/XMLSchema-instance';
//i:GetCityWeatherByZIPResult[1]/i:Success[1]] : Exception:Missing content for xpath [declare namespace i='http://www.w3.org/2001/XMLSchema-instance';
//i:GetCityWeatherByZIPResult[1]/i:Success[1]] in Response
like image 630
carlosgmercado Avatar asked Feb 22 '26 15:02

carlosgmercado


1 Answers

Using defined namespaces in SoapUI XPath assertions unnecessarily complicates things, and in some cases outright does not work. Start with just //*:GetCityWeatherByZIPResult/*:Success for your XPath, and work up from there as needed.

like image 153
SiKing Avatar answered Feb 24 '26 14:02

SiKing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!