2

What is the best library/framework to implement a SOAP webservice in scala?

an example of using scalaxb to implement a SOAP webservice?

Please, no heavy frameworks such as lift.

David Portabella
  • 12,390
  • 27
  • 101
  • 182
  • Why not use JAX-WS? The only real disadvantage is that your service has to deal with Java types, e.g. Scala collections aren't handled nicely. A immature re-implementation which doesn't lots of SOAPs less commonly used features is less useful. – Grogs Jan 12 '13 at 00:04
  • 1
    because JAXB sucks, and Scala has a nicer data-binding solution, scalaxb. Maybe it is possible to use JAX-WS with the scalaxb bindings, but I dind't find out how to do that. – David Portabella Jan 15 '13 at 08:37

2 Answers2

0

I guess there is no such library at the moment and maybe never will be, anyway, the situation is not that bad as it seems. You can create a Scala wrappers on top of existing Java SOAP libs. Have a look here for more info SOAP-proxy in Scala - what do I need? and for starters here: http://java.dzone.com/articles/basic-ws-scala-sbt-and-jee-6

Community
  • 1
  • 1
Kris
  • 5,714
  • 2
  • 27
  • 47
0

I ran into this very old question, and I'm not sure if the situation was different when it was posted, but here's an example using jax-ws, from https://redsigil.weebly.com/home/a-scala-soap-web-service.

@WebService(
  targetNamespace = "http://com.redsigil/soapserver",
  name = "com.redsigil.soapserver",
  portName = "soap",
  serviceName = "SoapServerSample")
@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
@Addressing(enabled = true, required = false)
class SoapServerImpl() {
  @WebMethod(action = "hashing")
  def test(@WebParam(name = "mystr", mode = WebParam.Mode.IN) value: String): String = sha256Hash(value)

  def sha256Hash(text: String): String =
    String.format("%064x",
      new java.math.BigInteger(1, java.security.MessageDigest.getInstance("SHA-256").digest(text.getBytes("UTF-8"))))
}

As you can see, it's fairly simple, although the annotations makes it a little ugly. The service defines one SOAP method ("test") which takes a string and returns its hash. The main function looks like this:

val myservice: SoapServerImpl = new SoapServerImpl()
val ep:Endpoint = Endpoint.publish("http://localhost:8080/test", myservice)

Yes, I know the OP indicate he did not like using jax-ws -- a little rant there in a comment, but consider that it's not something that cannot be solved through proper design and abstraction.

Will I Am
  • 2,614
  • 3
  • 35
  • 61