Since Endpoint.publish creates / uses a lightweight http server (as described here), is there a way to get access to said web server and, say, deploy a single html document at what would normally be the document root?

So if I did

Endpoint.publish("http://0.0.0.0:1234/webService");

Could I get the web server object and tell it to reply with index.html when somebody browses to http:/my.ip.add.res:1234/?

有帮助吗?

其他提示

Thanks to Evgeniy's direction, I just needed to take a closer look at the com.sun.net.httpserver package.

No, you can't get the Endpoint's webserver, but you can first make one and then publish the Endpoint on that server. Something to this effect:

HttpServer server = HttpServer.create(new InetSocketAddress(1234), 0);
HttpContext c = server.createContext("/webService");
Endpoint e = Endpoint.create(new WebService());
e.publish(c);

// Anything else you want to do with your server.

server.setExecutor(null);
server.start();

And presto. You have a web server with a web service published on it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top