As a general rule, services do not have a request or response in their
context (although you can certainly put them in if you need to).  Consider
that a service can be scheduled to run at 12AM in response to a job
scheduler and not an HTTP request.

You can call a service from you controller.xml file.  It can also be called
from the service scheduler, run synchronously or asynchronously from some
argitrary piece of java code, etc.

If you need the HttpServletRequest, you can get it from your controller like
this:

    <request-map uri="changeDelegator">
        <event type="java" path="org.ofbiz.webapp.event.CoreEvents"
invoke="changeDelegator"/>
        <response name="success" type="view" value="main"/>
        <response name="error" type="view" value="error"/>
    </request-map>

In this case, if you look at the changeDelegator() method, you will see that
it gets passed a request and response.  You will also note that
changeDelegator() is not to be found in a service.xml file(unless there just
happens to be a service with the same name)  because it is not a service.

In your services.xml file, you can require that it be called with a request
and a response in the context if that is what your needs are.

Hope this helps

Skip

-----Original Message-----
From: X Gylee [mailto:[EMAIL PROTECTED]
Sent: Monday, November 19, 2007 3:02 AM
To: user@ofbiz.apache.org
Subject: How to access session and request from Java service


In services.xml, I defined a service of type "java". According to
OFBiz documentation, this service received DispatchContext and Map as
its parameters.
How can I access the HTTP session and request from those input parameters?

I could not find an example in the OFBiz source about it. All the
codes in the source use the event of type "java" in controller.xml,
and this obviously provides HttpServletRequest as one of its input
parameters.

Reply via email to