用scala实现SOAP web服务



在scala中实现SOAP web服务的最佳库/框架是什么?

使用scalaxb实现SOAP web服务的一个例子?

请不要使用重物,如升降机。

我猜目前没有这样的库,也许永远不会有,无论如何,情况并不像看起来那么糟糕。您可以在现有的Java SOAP库之上创建Scala包装器。请点击这里了解更多Scala中的soap代理——我需要什么?对于初学者来说:http://java.dzone.com/articles/basic-ws-scala-sbt-and-jee-6

我遇到了这个非常古老的问题,我不确定发布时情况是否不同,但这里有一个使用jax-ws的示例,来自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"))))
}
如您所见,它相当简单,尽管注释使它有点难看。服务定义了一个SOAP方法("test"),该方法接受一个字符串并返回它的哈希值。主函数如下所示:
val myservice: SoapServerImpl = new SoapServerImpl()
val ep:Endpoint = Endpoint.publish("http://localhost:8080/test", myservice)

是的,我知道OP表示他不喜欢使用jax-ws——在评论中有一点咆哮,但考虑到这不是不能通过适当的设计和抽象来解决的问题。

最新更新