You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "I-Sampige, Srinivas" <sr...@boeing.com> on 2003/12/12 00:27:19 UTC

...getting null values

Hi
 I have implemented the ServiceLifecycle interface method in my web service implementation class and trying to read some input parameters from my web.xml. But, I don't see the input parameters at all in my "init" method even though I am able to print out other details like the real path to a couple of folders. Any ideas? Would be extremely grateful if somebody can take a quick look at this and help. I looked for typos in the web.xml but couldn't find any. Went to the extent of copying the init parameter section from the "SOAPMonitorService" of the web.xml.   Please see below for complete details -

Configuration - Axis 1.1; Tomcat 4.1.27; Java version is 1.4.2.

Output that comes on the console ( web.xml and code snippets are pasted after the output)-
--------------------------------------------------------------------------------------------------------------------
This is the init method of the service implementation-----
parameter names ----


attribute names ---
org.apache.catalina.jsp_classpath
javax.servlet.context.tempdir
org.apache.catalina.resources
AxisEngine
org.apache.catalina.WELCOME_FILES


Getting parameter values......
firstParam null
secondParam null


Misc values extracted from context......
server into Apache Tomcat/4.1.27
real path of / C:\workarea\ebtcWebServices\
real path of /docs C:\workarea\ebtcWebServices\docs
ctx.getMajorVersion() 2
ctx.getMinorVersion() 3
--------------------------------------------------------------------------------------------------------------------

The relevant snippet from my web.xml - 
----------------------------------------------------------------------------------------
<web-app>
  <display-name>Apache-Axis</display-name>
  <servlet>
    <servlet-name>AxisServlet</servlet-name>
    <display-name>Apache-Axis Servlet</display-name>
    <servlet-class>
        org.apache.axis.transport.http.AxisServlet
    </servlet-class>

    <init-param>
      <param-name>firstParam</param-name>
      <param-value>firstValue</param-value>
    </init-param>

    <init-param>
      <param-name>secondParam</param-name>
      <param-value>secondValue</param-value>
    </init-param>
  </servlet>
----------------------------------------------------------------------------------------

My init method looks like this-
-----------------------------------------------------------------------------------------
  public void init(Object context)
  {
    System.out.println("This is the init method of the service implementation-----");

    ServletEndpointContext servletEndPointCtx = (ServletEndpointContext) context;
    ServletContext ctx = servletEndPointCtx.getServletContext();

    System.out.println("parameter names ----");
    Enumeration paramNames = ctx.getInitParameterNames();
    while (paramNames.hasMoreElements())
    {
      System.out.println(paramNames.nextElement());
    }
    System.out.println("");
    System.out.println("");

    System.out.println("attribute names ---");
    Enumeration attributes = ctx.getAttributeNames();
    while (attributes.hasMoreElements())
    {
      System.out.println(attributes.nextElement());
    }
    System.out.println("");
    System.out.println("");

    System.out.println("Getting parameter values......");
    System.out.println("firstParam "+ctx.getInitParameter("firstParam"));
    System.out.println("secondParam "+ctx.getInitParameter("secondParam"));
    System.out.println("");
    System.out.println("");

    System.out.println("Misc values extracted from context......");
    System.out.println("server into "+ctx.getServerInfo() );
    System.out.println("real path of / "+ ctx.getRealPath("/"));
    System.out.println("real path of /docs "+ ctx.getRealPath("/docs"));
    System.out.println("ctx.getMajorVersion() "+ctx.getMajorVersion());
    System.out.println("ctx.getMinorVersion() "+ctx.getMinorVersion());
  }
----------------------------------

Thanks
Srinivas


Re: ...getting null values

Posted by Aaron Hamid <ar...@cornell.edu>.
ServiceLifecycle params and web.xml init params have nothing to do with 
each other.

Service params are configured in your WSDD.  Furthermore, 
ServiceLifecycle init method will NOT be called if implement it in your 
*Impl class.  You must implement it in your *Skeleton class (modify the 
generated source).  If you want your *Impl class to implement it, you 
must implement it in your Skeleton then manually call down to the 
implementation.

My expectation was that ServiceLifecycle would apply to the *Impl class, 
and I would would vote to change this behavior so that is the case.

Aaron Hamid

I-Sampige, Srinivas wrote:

>Hi
> I have implemented the ServiceLifecycle interface method in my web service implementation class and trying to read some input parameters from my web.xml. But, I don't see the input parameters at all in my "init" method even though I am able to print out other details like the real path to a couple of folders. Any ideas? Would be extremely grateful if somebody can take a quick look at this and help. I looked for typos in the web.xml but couldn't find any. Went to the extent of copying the init parameter section from the "SOAPMonitorService" of the web.xml.   Please see below for complete details -
>
>Configuration - Axis 1.1; Tomcat 4.1.27; Java version is 1.4.2.
>
>Output that comes on the console ( web.xml and code snippets are pasted after the output)-
>--------------------------------------------------------------------------------------------------------------------
>This is the init method of the service implementation-----
>parameter names ----
>
>
>attribute names ---
>org.apache.catalina.jsp_classpath
>javax.servlet.context.tempdir
>org.apache.catalina.resources
>AxisEngine
>org.apache.catalina.WELCOME_FILES
>
>
>Getting parameter values......
>firstParam null
>secondParam null
>
>
>Misc values extracted from context......
>server into Apache Tomcat/4.1.27
>real path of / C:\workarea\ebtcWebServices\
>real path of /docs C:\workarea\ebtcWebServices\docs
>ctx.getMajorVersion() 2
>ctx.getMinorVersion() 3
>--------------------------------------------------------------------------------------------------------------------
>
>The relevant snippet from my web.xml - 
>----------------------------------------------------------------------------------------
><web-app>
>  <display-name>Apache-Axis</display-name>
>  <servlet>
>    <servlet-name>AxisServlet</servlet-name>
>    <display-name>Apache-Axis Servlet</display-name>
>    <servlet-class>
>        org.apache.axis.transport.http.AxisServlet
>    </servlet-class>
>
>    <init-param>
>      <param-name>firstParam</param-name>
>      <param-value>firstValue</param-value>
>    </init-param>
>
>    <init-param>
>      <param-name>secondParam</param-name>
>      <param-value>secondValue</param-value>
>    </init-param>
>  </servlet>
>----------------------------------------------------------------------------------------
>
>My init method looks like this-
>-----------------------------------------------------------------------------------------
>  public void init(Object context)
>  {
>    System.out.println("This is the init method of the service implementation-----");
>
>    ServletEndpointContext servletEndPointCtx = (ServletEndpointContext) context;
>    ServletContext ctx = servletEndPointCtx.getServletContext();
>
>    System.out.println("parameter names ----");
>    Enumeration paramNames = ctx.getInitParameterNames();
>    while (paramNames.hasMoreElements())
>    {
>      System.out.println(paramNames.nextElement());
>    }
>    System.out.println("");
>    System.out.println("");
>
>    System.out.println("attribute names ---");
>    Enumeration attributes = ctx.getAttributeNames();
>    while (attributes.hasMoreElements())
>    {
>      System.out.println(attributes.nextElement());
>    }
>    System.out.println("");
>    System.out.println("");
>
>    System.out.println("Getting parameter values......");
>    System.out.println("firstParam "+ctx.getInitParameter("firstParam"));
>    System.out.println("secondParam "+ctx.getInitParameter("secondParam"));
>    System.out.println("");
>    System.out.println("");
>
>    System.out.println("Misc values extracted from context......");
>    System.out.println("server into "+ctx.getServerInfo() );
>    System.out.println("real path of / "+ ctx.getRealPath("/"));
>    System.out.println("real path of /docs "+ ctx.getRealPath("/docs"));
>    System.out.println("ctx.getMajorVersion() "+ctx.getMajorVersion());
>    System.out.println("ctx.getMinorVersion() "+ctx.getMinorVersion());
>  }
>----------------------------------
>
>Thanks
>Srinivas
>
>  
>