Reputation: 3398
I've inherited a Grails app which makes calls out to a web service, using javax.xml.ws* classes and I'm trying to find a way to mock the web service based on the WSDL for the integration tests. I realize that I can use one of the java soap implementations to build this, but I'd rather stay in groovy.
So my question is, is there an idiomatic groovy way to build a web service based on a WSDL?
Upvotes: 1
Views: 2135
Reputation: 2177
One approach that is pretty straightforward is to use Jetty to create a mock. It´s easy to create a mock that looks at the request and generates a response, especially if you´re using Groovy. For instance, create a template response file and use the XmlSlurper to fill in values. Then you can either start the mock in your tests or run it independently.
I found the following blog that roughly explains the basic concept:
http://olafsblog.sysbsb.de/lightweight-testing-of-webservice-http-clients-with-junit-and-jetty/
Upvotes: 1