Service 如何通过SoapUI中的groovy脚本从货币转换器服务响应中获取响应值?

Service 如何通过SoapUI中的groovy脚本从货币转换器服务响应中获取响应值?,service,groovy,scripting,automation,soapui,Service,Groovy,Scripting,Automation,Soapui,我正在使用Currency Converterwebservice在SoapUI Pro中练习groovy脚本 在这里,我创建了一个属性,该属性应该通过groovy脚本获得货币转换器服务的响应/输出 为此,我尝试使用以下脚本获取所有原始响应数据:( 我需要得到准确的结果,即转换值并分配给属性 谁能给我提供正确的groovy脚本 请求: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xm

我正在使用Currency Converterwebservice在SoapUI Pro中练习groovy脚本

在这里,我创建了一个属性,该属性应该通过groovy脚本获得货币转换器服务的响应/输出

为此,我尝试使用以下脚本获取所有原始响应数据:(

我需要得到准确的结果,即转换值并分配给属性

谁能给我提供正确的groovy脚本

请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:ConversionRate>
         <web:FromCurrency>USD</web:FromCurrency>
         <web:ToCurrency>INR</web:ToCurrency>
      </web:ConversionRate>
   </soapenv:Body>
</soapenv:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <ConversionRateResponse xmlns="http://www.webserviceX.NET/">
         <ConversionRateResult>60.54</ConversionRateResult>
      </ConversionRateResponse>
   </soap:Body>
</soap:Envelope>

美元
印度卢比
响应:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:ConversionRate>
         <web:FromCurrency>USD</web:FromCurrency>
         <web:ToCurrency>INR</web:ToCurrency>
      </web:ConversionRate>
   </soapenv:Body>
</soapenv:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <ConversionRateResponse xmlns="http://www.webserviceX.NET/">
         <ConversionRateResult>60.54</ConversionRateResult>
      </ConversionRateResponse>
   </soap:Body>
</soap:Envelope>

60.54
谢谢

Karunagara Pandi

首先,您需要访问响应

def conversionRateResult = context.expand( '${step_name#Response#//*:ConversionRateResult}' )
然后,将其指定给属性取决于多个因素:1)从何处执行操作,以及2)希望将属性指定给何处

要从脚本步骤抓取层次结构,请执行以下操作:

testRunner.testCase.setPropertyValue("property_name", conversionRateResult)
考虑浏览和