SoapUI getting request parameters in mock service script

前端 未结 4 1758
忘掉有多难
忘掉有多难 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:23

    If you want to access SOAP request and do some XPath processing, there's an easier way to do it in soapUI thanks to the power of GPath and XmlSlurper.

    Here's how you would access the customer number:

    def req = new XmlSlurper().parseText(mockRequest.requestContent)
    log.info "Customer #${req.foo.data.CustomerNumber}"
    

    As of Groovy 1.6.3 (which is used in soapUI 2.5 and beyond), XmlSlurper runs in namespace-aware and non-validating mode by default so there's nothing else you need to do.

    Cheers!
    Shonzilla

提交回复
热议问题