2

I have a simple question about deploying web services. Currently I have two endPoints, see below:

Endpoint.publish("http://localhost:8000/eCalcWS/eCalc", new eCalc());

Endpoint.publish("http://localhost:8001/eCalcWS/eCalc_service", new eCalc_service());

Is it possible to have two web services on the same address? How would I do that?

Mitja Rogl
  • 894
  • 9
  • 22
  • 39
  • 1
    Why would you want two web servers on the same address? How do you plan on differentiating so you can be sure you get exactly the service you want? – mabako Nov 05 '12 at 20:35
  • I just want to publish two different classes on the same address. – Mitja Rogl Nov 05 '12 at 20:48

1 Answers1

2

Unfortunately you can not the way you want.
The design is that each endpoint is associated with web service implementor.
From spec:

The Endpoint class can be used to create and publish Web service endpoints. An endpoint consists of an object that acts as the Web service implementation (called here implementor) plus some configuration information, e.g. a Binding

and on publish (my emphasis):

publish(String address, Object implementor)
Creates and publishes an Endpoint for the given implementor. The binding is chosen by default based on the URL scheme of the provided address (which must be a URL). If a suitable binding if found, the endpoint is created then published as if the Endpoint.publish(String address) method had been called. The created Endpoint is then returned as the value of the method.

I remember I also encounter this problem quite a while back which is really bad as I needed to associate 2-3 different implementations with different URLs and it was impossible (got address already bind error).
The way I got around this if I recall was to create my own dispatcher.
I published an endpoint that accepted web service requests for multiple endpoints and dispatched the request to the corresponding implementation. I worked directly on the SOAP message.
But it was possible for me since the xml messages were really simple and quite few.
For you I would recommend to publish in different endpoints if your web service implementations are non-trivial and have complicated messages and expect a lot of clients as the endpoint really just deploys a simple http server under the hood.

Cratylus
  • 52,998
  • 69
  • 209
  • 339