在SOAP UI的测试用例XPATH上获取节点时出错

car*_*ado 3 xml xpath soap soapui

我在使用SOAP UI入门教程时遇到困难,因为我无法为简单的测试生成断言条件.我正在使用XPATH方法测试以下SOAP消息:

<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> 
Run Code Online (Sandbox Code Playgroud)

我正在使用以下Xpath表达式:

declare namespace i='http://www.w3.org/2001/XMLSchema-instance';
//i:GetCityWeatherByZIPResult[1]/i:Success[1]
Run Code Online (Sandbox Code Playgroud)

这是错误:

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
Run Code Online (Sandbox Code Playgroud)

SiK*_*ing 8

在SoapUI中使用已定义的命名空间XPath断言不必要地使事情变得复杂,并且在某些情况下完全不起作用.从//*:GetCityWeatherByZIPResult/*:SuccessXPath 开始,根据需要从那里开始工作.