Scala + JDK6 annotations = Simple Web Service < 20 LOC

I’ve recently had the fortune to inherit the Promethean task of evaluating a number of vendor systems, whose main interface to existing ‘enterprise‘ software/systems is via a SOAP Web Service gateway. As intriguing as this may sound, I’ve found the snippet of code below to be an incredibly useful starting point when trying to rapidly knock up a sample integration endpoint.

The annotations are all from the standard JDK6 suite and only the syntax here is Scala specific. I happen to have given the object the same name as the private class (thus creating a ‘companion object‘), but this is a nicety rather than a necessity (an added nicety would be to be able to chain imports a la import javax.jws.soap.{SOAPBinding,SoapBinding.STYLE} – for which there is a related feature available for imports in Scala 2.8). Nonetheless, this provides a solid launchpad from which I’ve been able to further develop my integration tests.

Feel free to take the code above and compile (scalac WhateverNameOfFile.scala) and run (scala ObjectName e.g. scala MinimalSoapServer). The endpoint can be accessed at: http://localhost:8080/wstest and the wsdl seen at http://localhost:8080/wstest?wsdl


I personally test using SOAPUI, which I’ve found to be a very useful tool.

Hope this is of some use, and happy hacking !

Leave a Reply