Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save magohl/95723d6842c7b35847eca4ae16150955 to your computer and use it in GitHub Desktop.
Save magohl/95723d6842c7b35847eca4ae16150955 to your computer and use it in GitHub Desktop.
SoapUI - Mock response script Random content
script:
def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent )
def someInput = holder["//*[local-name()='SomeInput']"]
def random = Math.random()
requestContext.someInput = someInput
requestContext.randomText = random.toString()
response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://kramerica-industries.lan/webservices/dummyservice/1.0" xmlns:res="http://oresundsbron.com/types/result">
<soapenv:Header/>
<soapenv:Body>
<ns:DoStuffResponse>
<ns:SomeResult>
<!--Mocked from SoapUI-->
<res:ID>${someInput}</res:ID>
<res:Description>Here is a random number ${randomText}. Now was it cached or not?</res:Description>
</ns:SomeResult>
</ns:DoStuffResponse>
</soapenv:Body>
</soapenv:Envelope>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment