SoapUI getting request parameters in mock service script

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

    Extending http://www.soapui.org/soap-mocking/creating-dynamic-mockservices.html and based on http://www.soapui.org/apidocs/com/eviware/soapui/support/xmlholder.html I came up with this:

    // Create XmlHolder for request content
    def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent )
    holder.namespaces["ns3"] = "ns3"
    
    // Get arguments
    def custNo = holder.getNodeValue("//ns3:CustomerNumber")
    context.setProperty("custNo", custNo)
    

提交回复
热议问题