What JVM-based scripting language support @WebService to create services at runtime?

六眼飞鱼酱① 提交于 2019-12-03 03:10:27

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

Update to add an example:

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...'

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).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!