Java Webservice Basic

The following example shows ho to start a web service under Java6 or higher. This example does not show the implementation of the service itself, but the configuration of the web server. The implementation of the service is the object serviceImpl. There is explicitly created an object of the class which is then configured.

There is no exception handling shown here.

[code lang=”java”] import;

httpServer = HttpServer.create(new InetSocketAddress(interfaceName, port), 0);
HttpContext httpContext = httpServer.createContext("/path");
Endpoint endpoint = Endpoint.create(serviceImpl);

Further articles will describe how to configure more aspects of the server (threads, SSL, …)

Leave a Reply

Your comment will only be visible after moderation. Your email address will not be published.