如果我的服务器只有一个端点:
Endpoint endpoint = Endpoint.publish("http://localhost:6789/webservice/library", new LibraryImpl());
客户端可以通过
连接到它LibraryImplService service = new LibraryImplService();
LibraryInterface library = service.getLibraryImplPort();
如果我有多个端点:
Endpoint endpoint1 = Endpoint.publish("http://localhost:6789/webservice/library", new LibraryImpl());
Endpoint endpoint2 = Endpoint.publish("http://localhost:6799/webservice/library", new LibraryImpl());
Endpoint endpoint3 = Endpoint.publish("http://localhost:6809/webservice/library", new LibraryImpl());
如何让我的客户端连接到正确的URL? 而不是
LibraryInterface library = service.getLibraryImplPort();
我可以简单地使用已知的端口号吗?例如,如果我想连接到endpoint1
发布的网址,这会有用吗?
LibraryInterface library = 6789;
答案 0 :(得分:0)
您需要更改客户端将连接到的整个地址字符串。 JAX-WS不提供仅改变端口的方法。那你将拥有什么
BindingProvider bndProvider = (BindingProvider)library;
bndProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:6789/webservice/library");