Discussions

XML & Web services: Can the webservice do the following

  1. Can the webservice do the following (4 messages)

    Hi,

    I am new to webservices.

    Assume in a j2ee container one web application is running.
    Also there is a web servie running as well in the same box.


    Assume there is a application scope variable in the above web application (eg.static variable).

    The question is can the web service access that variable and update.

    Waiting for a quick solution.


    Thanks
  2. Can the webservice do the following[ Go to top ]

    Hi,

    If you are building Web services over Apache Axis servlet or adding Web service calls on existing JSP/Servlets, then you can use any static variable from the application code in your web service calls. In axis, you can access HttpServletRequest.

    Here is a little piece of code.

    /**
         * demo message context stuff
         * @return list of request headers
         */
        public String[] list() {
            HttpServletRequest request = getRequest();
            Enumeration headers=request.getHeaderNames();
            ArrayList list=new ArrayList();
            while (headers.hasMoreElements()) {
                String h = (String) headers.nextElement();
                String header=h+':'+request.getHeader(h);
                list.add(header);
            }
            String[] results=new String[list.size()];
            for(int i=0;i<list.size();i++) {
                results[i]=(String) list.get(i);
            }
            return results;
        }


    Sithu
  3. Hi,

    What I meant was whether the Web service can access the variable(scope is Application) which resides in a different web application.

    The following answer is all about getting a request object.

    Other thing is for the web services will be host in WebLogic. We do not use Apache Axis.

    Waiting for early reply.

    Lalith
  4. if the web application is in a different to that which will host the Web Service, then it seems that it is not possible to share information. Correct me if i am wrong.

    If you have control over the application then you can build a web service into it and redeploy it. If the Web service and some variable are in the same web app, then it it much easier.

    Hope this helps,

    Saqib

    http://galaxy.sagadc.com/
    - Create Web Services in 15 minutes -
  5. My argument is Web service runs in a different context and the web application runs in a different context.

    Due to this reason the web service cannot access the variable in the web application.

    Let me know if am wrong.