Re: Can a Web Service know where itself is deployed??

From: Andy Wolf <>
Date: Sun, 09 May 2004 20:32:34 +0200


Guadalupe Ortiz wrote:
> I have a web service developed with jaxrpc. I can deploy it anywhere. Can
> the web service know at run time where it has been deployed? Because I can
> even deploy it, the same service, in two different uris, can it distinguish
> in which uri its operations are invoked??

Well, I wonder what difference it makes where the service is running but
you can find out the ContextName via the ServletEndpointContext which is
available through the ServletLifecycle:

public class MyServiceImpl implements MyService, ServiceLifecycle {
    private ServletEndpointContext sec;


    public void myRemoteMethod(){
       String contextName =


    public void destroy() {

    public void init(Object arg0) throws ServiceException {
       sec = (ServletEndpointContext)arg0;

For the name of the virtual host under which this service is deployed
you might want to check the servlet container attributes which can be
accessed via the ServletContext as well.


To unsubscribe, e-mail:
For additional commands, e-mail: