Forum Discussion

maxpaynebupt's avatar
maxpaynebupt
Occasional Contributor
8 years ago

How can I dynamicly route the request to different resource in a Rest MockService?

I want to create a REST mock service with path parameters. 

Something like http://localhost:8080/{deviceid}/edit/

the deviceid is a property which should be set in the mockservice property,

I am trying to write groovy script in mockservice's 'OnRequest Script', but, how can I route the request?

thanks.

    • maxpaynebupt's avatar
      maxpaynebupt
      Occasional Contributor

      hi, thanks

      but , this would not work for me, I think , soapui would try to match the path to the resource from left to right of the path, if the dynamic parameters is at the tail of that url, yes, we can write the dispatch script to selectively send the response, but , if the dynamic parameter is in the middle of a resource url, it would fail to match and dispatch.

       

      such as:

      the resouce is at : /${productid}/subitems/

      I cant write a resource like this, the resource path can be matched.

      • nmrao's avatar
        nmrao
        Champion Level 3
        Ok, I got you what you say. Haven't tried like that.