什么基于JVM的脚本语言支持@WebService在运行时创建服务? [英] What JVM-based scripting language support @WebService to create services at runtime?

查看:160
本文介绍了什么基于JVM的脚本语言支持@WebService在运行时创建服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处于需要能够在运行时创建和公开Web服务的情况。 (即没有javac - 编译步骤)。

I am at a situation where I need to be able to create and expose a webservice at run time. (i.e. no "javac"-compilation step).

是否存在基于JVM的脚本语言,它对JAX-WS有很好的支持,所以我可以编写一个中央引擎Java,然后让脚本语言创建包含Web服务方法的片段(使用@WebService或@WebMethod注释),然后将其传递给

Is there a JVM-based scripting language that has good support for JAX-WS so I can write a central engine in Java, and then just let the scripting language create the snippets containing the web service methods (with either @WebService or @WebMethod annotations) which can then be passed to

http://docs.oracle.com/javase/6/docs/api/javax/xml/ws/Endpoint.html#publish(java.lang.String,java.lang.Object)

如果可能,请提供一个如何正确执行此操作的示例。

If at all possible, please provide an example of how to do it correctly.

有任何建议吗?

推荐答案

很多人都这样做,那个最像Java的人并且支持你想要的东西可能会很时髦。

Many do, the one that is most Java-like and supports what you want would probably be groovy.

更新以添加示例:

有很多可通过goog获得搜索。我所知道的最好的是这里因为这会引导您完成一个有效的示例。此链接指向另一个专注于groovy的问题/答案网站。他们将向您介绍这个简单的示例:

There are lots of them available via a google search. The best one I know about is here as this should walk you through an example that works. This link is to another question/answer site focused on groovy. They walk you through this simple example:

如果您尝试使用此网站并发现它没有指导意义,请在此处提供反馈。同样,如果你搜索并找到一个你发现更好/更容易理解的,请在此处添加。我不能从同样的角度出发,因此你会有更多的贡献,我会这样做。

If you try this site and find that it is not instructive, please provide that feedback here. Likewise, if you do search and find one that you find better/easier to understand, please add that here. I can't come at from that same perspective, thus you would have more to contribute in this vein that I.

Geom.groovy
-------------------
package webservices

import javax.jws.WebService
import javax.jws.soap.SOAPBinding.Style
import javax.jws.soap.SOAPBinding

@WebService
@SOAPBinding(style=Style.RPC)
interface Geom {
    double getArea(double val)
}

Circle.groovy
-------------------
package webservices

import javax.jws.WebService

@WebService(endpointInterface='webservices.Geom')
class Circle implements Geom {
        double getArea(double r) { Math.PI*r*r }
}

publish.groovy
--------------------
package webservices

import javax.xml.ws.Endpoint

Endpoint.publish('http://localhost:5555/circle',new Circle())
println 'ready to receive requests...'

林我提供的k可能最终会破坏或被删除。然而(IMO),如果(当?)技术向更新/更好的方向发展,这很可能会发生。虽然我从上面复制了代码,但引用还有其他非常有用的信息和指针(例如使用SoapUI)。

The link I provided may eventually break or be removed. However (IMO), this would most likely occur if (when?) the technology moves forward to something newer/better. While I have duplicated the code from there above, the reference has other very useful information and pointers (such as the use of SoapUI).

这篇关于什么基于JVM的脚本语言支持@WebService在运行时创建服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆