Tuesday, June 4, 2013

A SoapUI Plugin for Runscope

Another week - another cool API-related service! This time it's Runscope - a web application that basically allows you to record and replay API requests and responses that get routed through their platform - with a bunch of additional bells and whistles.  It was launched publicly at GlueCon a couple of weeks ago - and although I'm not quite sure of the use case I couldn't resist creating a very simple SoapUI plugin that easily lets you run your requests through their platform instead of directly to the target endpoint.

To run your requests through Runscope you simply need to modify the endpoint as described at https://www.runscope.com/docs - obviously an easy task for a SoapUI RequestFilter - let's get busy!

The Plugin Code


The plugin code is extremely simple; the main artifact is a SoapUI RequestFilter that modifies the request endpoint as described in the Runscope documentation. Since a bucket-id is required, the plugin looks for a Project-level property named "RunscopeBucket" - if it exists its value will be used accordingly.

The filter is written in groovy:


(see the latest version at GitHub)

The only other thing needed in the plugin is a listeners.xml file that adds this listener to the SoapUI RequestFilter Registry:


The project as a whole looks as follows in IntelliJ


and can be found on GitHub at https://github.com/olensmar/soapui-runscope-plugin.

In action


Download the plugin from sourceforge and save it into the SoapUI/bin/plugins folder - when SoapUI starts you will see the following in the SoapUI log:


Now add a "RunscopeBucket" property to your SoapUI project and set it to a valid Runscope Bucket identifier:


All requests in your project will now be sent through Runscope - and recorded by it for inspection, replay, etc. You can see the modified endpoint in the Raw tab of the request:



(and of course you can see the captured requests in the Runscope console)

Be cautious though; when I say all requests, I mean all requests - included those in a LoadTest, SecurityTest, etc. If you forget to unset the "RunscopeBucket" property you can easily fill up your bucket at Runscope in no time.

Runscope has the option of not forwarding your request to its target endpoint - so you can "debug" and record the outgoing request without loading the target service - to enable that add a property named "RunscopeCapture" to your project and set it to "true" - this will modify the outgoing endpoint accordingly.

Wrapping up!


That's it - nice and easy. Download the plugin from sourceforge and have a go - let me know if you have any issues or want any improvements!

Thanks,

/Ole