8

I am trying to create a mock webservice for a POST method on SoapUI. I made a REST Project, then created a MockService, a MockAction and defined a couple responses and resource paths. It works fine if I define a fixed regular path relative to my Service, for example method/postmethod to be invoked at http://localhost:8080/method/post, it works well.

What I want to do, however, is define my method with path parameters, such as this: http://localhost:8080/method/{par1}/{par2}/{par3}/post. The application we want to test, which will be invoking our mock service, uses this type of parameter extensively, so we cannot just create one method for each possible combination.

Is it possible to define a mock POST method with that type of path parameter? Is it possible to parse the parameters and use them in the output response? If yes, then how?

Eduardo Z.
  • 633
  • 3
  • 10
  • 32

1 Answers1

6

Please enable the script method in responding the request that came to mock, there is a default script posted by soapui , which tells how to access the path parameters, headers, body . please use that , attached the pic for reference.enter image description here

Maak
  • 4,720
  • 3
  • 28
  • 39
Suman g
  • 477
  • 3
  • 14
  • 8
    I got it now! The trick is to not specify the full request path, but specify it just up to the point where my request parameters start to show up. So if I have a path like /request/path/{param1}/path/{param2}/path/{param3}, I have to make a Mock Action just as far as /request/path. If I invoke the full path that Mock Action responds and then I have to take care of handling the parameters inside my script. – Eduardo Z. May 20 '16 at 13:15
  • 2
    But a pain if you have subresources you'd like to "catch" with templates or wildcards, and resources above or below you'd like to handle with different mock actions :-( – dbreaux Apr 04 '18 at 17:32
  • @dbreaux agree. It's a bit of a trade-off. I still have to find the "perfect" mock server. – LppEdd Apr 26 '19 at 14:45