2016-03-03 100 views
0

我在编写SoapUI中的groovy脚本时,在编写下面提到的代码时,出现类似“No such propety:GetSupplierByCityResult for class:Script1”的错误。Groovy脚本在SoapUI中发生错误

了SoapUI反应:

<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> 
    <GetSupplierByCityResponse xmlns="http://www.webservicex.net/"> 
    <GetSupplierByCityResult>false</GetSupplierByCityResult> 
    <SupplierDataLists> 
     <SupplierDatas/> 
     <TotalRecords>0</TotalRecords> 
    </SupplierDataLists> 
    </GetSupplierByCityResponse> 
</soap:Body> 
</soap:Envelope> 

Groovy代码:

//Define Groovy Utils and holder for validating the XML reponse content 

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) 
def holder = groovyUtils.getXmlHolder(messageExchange.responseContent) 

    //Define the NameSpace 
    holder.namespaces["ns"] = "http://www.webservicex.net" 

    //Get the Value of the Node 'GetReservationRSResult' and assign to a  variable 
    def GetReservationResponse = holder.getNodeValue("//GetSupplierByCityResult") 

    //print the value of the GetReservationResponse 
    log.info "The GetReservationResponse " + GetReservationResponse 

    //Comparing the value to print 'Pass' or 'Fail' 
    if(GetSupplierByCityResult=="false") 
    { log.info "Pass" } 
    else 
    { log.info "fail"} 

请帮我解决这个问题。

回答

0

在行:

if(GetSupplierByCityResult=="false") 

你的变量称为GetReservationResponse,不是吗?

看起来从行方式:

def GetReservationResponse = holder.getNodeValue("//GetSupplierByCityResult") 

变量也应该与小写字符(这是作为否则Groovy中可能会猜到你在谈论一个类时,你拿出遵循一个好习惯开始与一个不好名称的变量)

+0

谢谢tim_yates为您的支持,现在它工作正常。 – Sai