Hi all,
I wish to develop webservice using axis which access application level object,which live as long as application life time. I want to access ServletContext, so i write my web service class as Servlet ....
//loader servlet to load application object
import javax.servlet.*;
import javax.servlet.http.*;
public class Loader extends HttpServlet{
public void init(ServletConfig conf){
Integer counter = new Integer("0");
conf.getServletContext().setAttribute("cnt",counter);
System.out.println("::::::::::::::::::::::: sucessful!");
}
}
.......
//in web.xml
<servlet>
<servlet-name>Loader</servlet-name>
<servlet-class>Loader</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
...
//here is web service file "CounterWebService.jws"
import javax.servlet.*;
import javax.servlet.http.*;
public class CounterWebService extends HttpServlet{
ServletContext context;
public void init(ServletConfig conf){
context = conf.getServletContext();
}
public String getCounter(String str){
Integer counter = (Integer)context.getAttribute("cnt");
if(counter==null) return "Dont get application object";
counter = new Integer(counter.intValue()+1);
context.setAttribute("cnt",counter);
return String.valueOf(counter.intValue());
}
}
and when i call
http://localhost:8080/axis/CounterWebService.jws tomcat command display the following error
- The class javax.servlet.ServletConfig is defined in a java or javax package an
d cannot be converted into an xml schema type. An xml schema anyType will be us
ed to define this class in the wsdl file.
I'd like to know we can access applcation level object from web service? If then how to access it.
Thanks in advance
kaze