Reputation: 6258
I'm able to independently run a WebService
and an httpServer
by themselves, but when I'm running both, the web-service wsdl
url no longer works. I was hoping to do this so I could call web-services from javascript to the same URL without having cross origin issues.
Is this even possible?
public class Main {
public static void main(String[] args) throws Exception {
int port = 8888;
/* This works without httpServer running */
Endpoint.publish("http://localhost:" + port + "/ws/someService", new SomeService());
/* This works without Endpoint running */
HttpServer httpServer = HttpServer.create(new InetSocketAddress(port), 0);
httpServer.createContext("/someHandler", new SomeHandler());
}
}
Upvotes: 2
Views: 257
Reputation: 925
Try with different ports. For example, if you use 8888 for the Endpoint, use 8890 or something for the HttpServer.
The EndPoint uses an embedded HTTP Server implementation which is included as part of Java. So, you are essentially trying to use two different HTTP servers on the same port, which I think won't work. You should use different ports to make this work.
Upvotes: 1