users@jax-rpc.java.net

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

From: Andy Wolf <andy.wolf_at_schwaben.de>
Date: Mon, 10 May 2004 00:29:55 +0200

Hello,

Guadalupe Ortiz wrote:
> I get the next compilation error "This compilation unit indirectly
> references the mising type javax.servlet.ServletContext" How can I solve it,
> please? and how do I use the information you provided me for example inside
> the method "bookAvailability" to get the context if it is posible in this
> way??

What JAX-RPC runtime do you use ? You should have
javax.servlet.ServletContext within your classpath. In the JWSDP 1.3 it
is in common/lib/servlet-api.jar. And you have to import the
ServiceException as well...

> public boolean bookAvailability (String ISBN) {
> boolean Result=false;

        String contextName =
           sec.getServletContext().getServletContextName;

        if(contextName.equals("/english")) {
           System.err.println("English context used...");
        }

> if ((ISBN.compareTo("1111"))==0)
> Result=true;
> return Result;
> }

See the JavaDocs for ServiceLifecycle, ServletEndpointContext and
ServletContext for more details.

Please bear in mind that from a design point of view it might not be a
good idea to have a service with an identical WSDL interface description
to behave differently according to the endpoint address. I would rather
encourage you to use a separate method parameter for this purpose.

regards...Andy


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net