How to return dynamic response in SoapUI MockService

*爱你&永不变心* 提交于 2019-12-03 15:01:55

I do it with "canned responses" and xpath queries. To do this, you'll set up a series of dispatch handlers in the mockservice to match requsts with respones. Suppose you've got Request1, Request2, Response1, Response2. Use the "Query Match" dispatch method, to match an XPATH expression. On that match, return the desired response. i.e. if you find ID1 in the xpath, return the canned Response1.

Also, the PRO version does a great job with the XPATH, so you don't have to hand code it. i.e. it can look at a response click on the thing that you want to trigger on (in your case, ID1) and it builds the XPATH expression for you. I requested a PRO license, just based on that. Currently awaiting budgeting...

IMO, much easier to get started than figuring out groovy.

Chris

0x89

Instead of xpath, you could also use XmlSlurper.

def req = new XmlSlurper().parseText(mockRequest.requestContent)
def reqRef = req.record.identifier

Shamelessly ripped of from this question's answers, please don't hurt me.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!