代码之家  ›  专栏  ›  技术社区  ›  desperado06

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

  •  0
  • desperado06  · 技术社区  · 6 年前

    希望将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 回复  |  直到 6 年前
        1
  •  1
  •   Rao CrashOverload    6 年前

    在请求中,更改为:

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

    收件人:

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