SoapUI getting request parameters in mock service script

前端 未结 4 1761
忘掉有多难
忘掉有多难 2020-12-05 02:52

This is probably a very easy one for all SoapUI regulars.

In a SoapUI mock service response script, how do I extract the value inside the request I\'m replying to?<

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 03:30

    One more example:

    def request = new XmlSlurper().parseText(mockRequest.requestContent)
    def a = request.Body.Add.x.toDouble()
    def b = request.Body.Add.y.toDouble()
    context.result = a + b
    

    In this example we get two parameters from the request and convert them to doubles. This way we can perform calculations on the parameters. The sample SoapUI response for this example is:

    
       
       
          
             ${result}
          
       
    
    

    You can see how the calculations result is passed back to the response.

提交回复
热议问题