users@jax-rpc.java.net

Re: Context in webservices

From: Binildas C. A. <binildas_at_IBSPLC.COM>
Date: Sun, 12 May 2002 10:28:27 +0530

import javax.xml.rpc.server.ServiceLifecycle;
//...

public class SunRegImpl implements SunRegPort, ServiceLifecycle {

        private String dbUrl;

        public void init(Object context) {

                log("SunRegImpl.init...");
                dbUrl =
((ServletContext)context).getInitParameter("dbUrl");
        }

        public void destroy() {

                log("SunRegImpl.destroy...");
                //release the database connection
        }
        // Other code goes here
}

<web-app>
   <context-param>
      <param-name>dbUrl</param-name>
      <param-value>jdbc:cloudscape:sunregDB</param-value>
   </context-param>
   <servlet>
      <servlet-name>SunregEndpoint</servlet-name>
      <servlet-class>com.sun.xml.rpc.server.http.JAXRPCServlet
      </servlet-class>
      <init-param>
         <param-name>configuration.file</param-name>
         <param-value>
             /WEB-INF/SunRegService_Config.properties
         </param-value>
      </init-param>
      <load-on-startup>0</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>SunregEndpoint
      </servlet-name>
      <url-pattern>/jaxrpc/*</url-pattern>
   </servlet-mapping>
</web-app>

Everything else remains the same. There is a descriptive article on
JAX-RPC in Sun's site by Arun and Beth, from where I have tried the above
piece of code...

Binildas C. A.
IBS Software Services (P) Ltd.
521-524 / NILA
Technopark Campus
Trivandrum - 695 581, India
Tel : ++91 - 471 - 700080 (Extn. 4272)
Fax : ++91 - 471 - 700078
mailto:binildas_at_ibsplc.com
http://www.ibsplc.com






Armond Avanes <armond333_at_YAHOO.COM>
Sent by: Public discussion on JAX-RPC <JAXRPC-INTEREST_at_JAVA.SUN.COM>
05/12/02 09:47 AM
Please respond to Public discussion on JAX-RPC


        To: JAXRPC-INTEREST_at_JAVA.SUN.COM
        cc:
        Subject: Re: Context in webservices


Hi Botond,

Would you please provide me the peice of code you've
used to reach into context from your web service class
?
I need to have session tracking on my web services.

Best Regards,
Armond

----------------------------
Thanks, thats working.

Another question would be, how can I deploy different
webservices in the same web application? I managed to
access the ServletContext, but the different
webservices use different ServletContexts. I know that
the ServletContexts are different for the individual
web applications, so I figured out, that the solution
would be to deploy my webservices in the same web
application.

Regards, Botond.



Simon Horrell wrote:

>Have a look at the JAX-RPC spec and check the
>javax.xml.rpc.server.ServiceLifeCycle interface. The
Web service
>endpoint class may implement this interface. Its
init() method has a
>single parameter which is a
javax.xml.rpc.server.ServletEndpointContext
>implementation provided by the JAX-RPC runtime
implementation. This
>allows access to the underlying
javax.servlet.ServletContext,
>javax.servlet.http.HttpSession etc. Note that the
parameter of the
>ServiceLifeCycle.init() method used to be a
>javax.servlet.ServletContext in earlier specs. Si.


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com