Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish JAX-WS endpoint with embedded Jetty 7

Can anybody help with this?

I want to use an embedded Jetty 7 as Endpoint. This is what I tried:

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();
}

}

But I cannot see whether this really uses Jetty instead of the default sun HttpServer.

One blog mentioned

 System.setProperty("com.sun.net.httpserver.HttpServerProvider",
       "org.mortbay.jetty.j2se6.JettyHttpServerProvider");

But there doesn't seems to be such HttpServerProvider in Jetty 7.

Thanks for any help, Axel.

like image 381
axelrose Avatar asked Oct 26 '09 16:10

axelrose


2 Answers

All what is necessary seems to be

System.setProperty("com.sun.net.httpserver.HttpServerProvider", "org.mortbay.jetty.j2se6.JettyHttpServerProvider");

The current contrib code from jetty-contrib/org/mortgay/jetty/j2se6 is not ready yet for Jetty 7. That's all.

like image 82
axelrose Avatar answered Oct 07 '22 15:10

axelrose


You could simply open the URL of the WSDL in Firefox and check the response headers with Firebug. You should get something like:

HTTP/1.1 200 OK
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Server: Jetty(7.1.2.v20100523)
like image 26
mas Avatar answered Oct 07 '22 13:10

mas