无法将groovy参数值传递给soapUI请求xml

时间:2018-02-22 13:25:58

标签: groovy soapui

想要将bankaTalimatNo参数传递给groovy脚本的后续请求。 我创建了一个名为bankaTalimatiNo的测试用例级属性。

在groovy脚本中,我迭代一个数组以正确设置值属性值,但生成的请求不会与属性值并行更改。

实现此目的的正确XML表达式应该是什么? 提前谢谢

   <soapenv:Header/>
   <soapenv:Body>
      <wso:kurumOdemesiSorgulaRequest>
         <wso:bankaTalimatiNo>${Properties#bankaTalimatiNo}</wso:bankaTalimatiNo>
      </wso:kurumOdemesiSorgulaRequest>
   </soapenv:Body>
</soapenv:Envelope>

和groovy脚本如下

project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("maliye")
testSuite = project.getTestSuiteByName("TestSuite 1");
testCase = testSuite.getTestCaseByName("TestCase 1");
testStep=testCase.testSteps["SOAP Request1"]

 File file = new File("C:/temp/test.txt")
      file.write "This is the first line\n"

def  String[] talimatNoArray = [
"3"


];

talimatNoArray.eachWithIndex{talimatNo, i->

 testCase.setPropertyValue("bankaTalimatiNo"  , "${talimatNo}");



    log.info "aaa"+ testCase.getPropertyValue("bankaTalimatiNo");
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
    context.bankaTalimatiNo=testStep.getPropertyValue("bankaTalimatiNo");
    def responseHolder=testStep.getPropertyValue("response");



    //Check if the response is not empty
    assert responseHolder, 'Response is empty or null'


}

生成的请求始终相同,表达式永远不会被评估

>  <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wso="http://maliye.yte.bilgem.tubitak.gov.tr/odeme/kurumodemesi/server/wso">
> <soapenv:Header/>    <soapenv:Body>
>       <wso:kurumOdemesiSorgulaRequest>
>          <wso:bankaTalimatiNo>${bankaTalimatiNo}</wso:bankaTalimatiNo>
>       </wso:kurumOdemesiSorgulaRequest>    </soapenv:Body> </soapenv:Envelope>

1 个答案:

答案 0 :(得分:1)

在请求中,更改为:

<wso:bankaTalimatiNo>${Properties#bankaTalimatiNo}</wso:bankaTalimatiNo>

要:

<wso:bankaTalimatiNo>${#TestCase#bankaTalimatiNo}</wso:bankaTalimatiNo>