Friday, 23 April 2010

Sponge: For When You're Using Soap

The Problem
At my current job we have a suite of applications that all have the same basic architecture:
  • A Java web-start client talking to...
  • A server side deployed in JBoss which talks to...
  • Back-end .NET web-services
The .NET services front the core systems that the Java application connects to. The Java application is provided to customers who want to do business with us.

Both the Java side and the .NET side have a problem when it comes to keeping a development environment up and running. The Java guys don't really want to have to run the .NET web-service on their machines, and the .NET guys don't really want to have to run JBoss. What tends to happen is that the Java team try to connect to a shared .NET service which is either:
  • Borked or...
  • Incompatible with the version of the code they are developing
Cue lots of wasted time for all involved as people stop that they are doing to fix the shared service.

A Workaround
I wanted to find a way to be able to run up a development environment on my PC without having to rely on the back-end .NET service. I did this with a combination of:
I used SoapTrace to record some Soap exchanges, and plugged the responses into some mock web-services in SoapUI. This worked but it was a total pain in the ass to set up. It took ages to record all the Soap exchanges I needed, then I had to fiddle around in SoapUI to generate the responses, then configure SoapUI to return different responses for different types of request.

What I really wanted was a way to be able to record a Soap session and, at the flick of a switch, use the recorded responses to mock the web-service calls in my development environment.

Enter Sponge
And so Sponge was born. Sponge has the following features:
  • It can act as a Soap router, sitting between the Soap client and the Soap service.
  • Soap exchanges can be saved, viewed, edited etc.
  • Entire Soap sessions can be stored and used to mock out web-service calls.
  • The user can choose which response to return for a particular request type at the click of a button.
  • Previously saved Soap requests can be re-sent to the service.
  • It has a plugin mechanism to enable requests or responses to be dynamically transformed before sending / after receiving.
Sponge is the tool that I couldn't find that allowed me to work the way I wanted to work.  On the Java side, once I have a session recorded I no longer need to rely on the .NET web-service. And on the .NET side, given a session they no longer need to run the Java side of the application in order to generate requests.

The Technology
I had 2 goals when writing Sponge:
  1. Create a tool to help me in my day to day development.
  2. Learn Clojure.
The meat of Sponge is implemented in Clojure, with a thin(ish) GUI layer written in Java (using the Netbeans GUI builder).

Screenshot
This screenshot shows the key features:

  1. The top half of the screen shows some Soap exchanges.
  2. The bottom half shows the Soap request (on the left) and response (on the right) for the currently highlighted exchange.
  3. The response is in edit mode. By double clicking on the text panel it is possible to edit the xml.
  4. The 3rd exchange is highlighed in green, and has 'R' in the info column. This indicates that this row will be replayed i.e. if any request comes in that matches the Namespace, URL and Soap method of the replay row, then that response will be returned.
  5. The Replays column shows the number of times that response has been replayed.
Interested?
You can download the latest version of Sponge from http://github.com/NeillAlexander/sponge. It is licensed under the Eclipse Public License, and all the source code is available in Github. I don't intend to do any more development at this point in time. It does what I need it to do.

Installation instructions are included in the distribution, and there is also some basic integrated help which describes how to use it.

Feedback
If you make use of this, let me know what you think. Leave a comment here, or raise an issue on Github, or whatever. I'd love to know that someone else finds this useful.

No comments:

Post a Comment