使用嵌入式Jetty 7发布JAX-WS端点
任何人都可以帮忙吗?
我想使用嵌入式Jetty 7作为端点。 这是我试过的:
public class MiniTestJetty { @WebService(targetNamespace = "http") public static class Calculator { @Resource WebServiceContext context; public int add(int a, int b) { return a + b; } } public static void main(String[] args) throws Exception { int port = 8080; Server server = new Server(port); Calculator calculator = new Calculator(); Endpoint.publish("http://localhost:" + port + "/calc", calculator); server.start(); server.join(); }
}
但我无法确定这是否真的使用Jetty而不是默认的sun HttpServer。
一篇博客提到过
System.setProperty("com.sun.net.httpserver.HttpServerProvider", "org.mortbay.jetty.j2se6.JettyHttpServerProvider");
但Jetty 7似乎没有这样的HttpServerProvider。
感谢任何帮助,Axel。
所有必要的东西似乎都是
System.setProperty("com.sun.net.httpserver.HttpServerProvider", "org.mortbay.jetty.j2se6.JettyHttpServerProvider");
来自jetty-contrib / org / mortgay / jetty / j2se6的当前贡献代码还没有为Jetty 7做好准备。这就是全部。
您只需在Firefox中打开WSDL的URL并使用Firebug检查响应头。 你应该得到类似的东西:
HTTP/1.1 200 OK Content-Type: text/xml;charset=utf-8 Transfer-Encoding: chunked Server: Jetty(7.1.2.v20100523)
该课程改名为
org.eclipse.jetty.http.spi.JettyHttpServerProvider
我从http://download.eclipse.org/jetty/updates/jetty-bundles-9.x/9.0.6.v20130930/获取了它:
适用于Java 7的V9.0.6
V9.3.2适用于Java 8