You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Patrick <pa...@gmail.com> on 2010/03/09 16:08:54 UTC

How to get a session from a service?

I have a service definition
public static Map<String, Object> sendMailFromScreen(DispatchContext
dctx, Map<String, ? extends Object> rServiceContext)

How can I get the session from this?  Thanks
Patrick

Re: How to get a session from a service?

Posted by Scott Gray <sc...@hotwaxmedia.com>.
Only if "session" is specified as an attribute/parameter in the service definition, which is basically what I described below.

You absolutely cannot just retrieve the session from any service without defining it as an attribute and then passing it in from the calling code.

Regards
Scott

On 9/03/2010, at 10:46 AM, Ruth Hoffman wrote:

> Hi Patrick:
> Actually, you can get a session from within a Java service. Try:
> 
> HttpSession session = (HttpSession)context.get("session");
> 
> Regards,
> Ruth
> ----------------------------------------------------
> Find me on the web at http://www.myofbiz.com or Google keyword "myofbiz"
> ruth.hoffman@myofbiz.com
> 
> 
> Scott Gray wrote:
>> You can't, services are isolated and not aware of the http request/response cycle.  You need to explicitly pass in any parameters that the service will use.
>> 
>> Regards
>> Scott
>> 
>> HotWax Media
>> http://www.hotwaxmedia.com
>> 
>> On 9/03/2010, at 8:08 AM, Patrick wrote:
>> 
>>  
>>> I have a service definition
>>> public static Map<String, Object> sendMailFromScreen(DispatchContext
>>> dctx, Map<String, ? extends Object> rServiceContext)
>>> 
>>> How can I get the session from this?  Thanks
>>> Patrick
>>>    
>> 
>>  


Re: How to get a session from a service?

Posted by Ruth Hoffman <rh...@aesolves.com>.
Hi Patrick:
Actually, you can get a session from within a Java service. Try:

HttpSession session = (HttpSession)context.get("session");

Regards,
Ruth
----------------------------------------------------
Find me on the web at http://www.myofbiz.com or Google keyword "myofbiz"
ruth.hoffman@myofbiz.com


Scott Gray wrote:
> You can't, services are isolated and not aware of the http request/response cycle.  You need to explicitly pass in any parameters that the service will use.
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 9/03/2010, at 8:08 AM, Patrick wrote:
>
>   
>> I have a service definition
>> public static Map<String, Object> sendMailFromScreen(DispatchContext
>> dctx, Map<String, ? extends Object> rServiceContext)
>>
>> How can I get the session from this?  Thanks
>> Patrick
>>     
>
>   

Re: How to get a session from a service?

Posted by BJ Freeman <bj...@free-man.net>.
this is something that confused me at first.
Events pass the HTTP so the java code.
services engine converts the session into the context named parameters.
take a look at the HttpEngine.java


=========================
BJ Freeman
http://bjfreeman.elance.com
Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
Specialtymarket.com <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man
Linkedin
<http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>


Ruth Hoffman sent the following on 3/9/2010 9:46 AM:
> Hi Patrick:
> Actually, you can get a session from within a Java service. Try:
> 
> HttpSession session = (HttpSession)context.get("session");
> 
> Regards,
> Ruth
> ----------------------------------------------------
> Find me on the web at http://www.myofbiz.com or Google keyword "myofbiz"
> ruth.hoffman@myofbiz.com
> 
> 
> Scott Gray wrote:
>> You can't, services are isolated and not aware of the http
>> request/response cycle.  You need to explicitly pass in any parameters
>> that the service will use.
>>
>> Regards
>> Scott
>>
>> HotWax Media
>> http://www.hotwaxmedia.com
>>
>> On 9/03/2010, at 8:08 AM, Patrick wrote:
>>
>>  
>>> I have a service definition
>>> public static Map<String, Object> sendMailFromScreen(DispatchContext
>>> dctx, Map<String, ? extends Object> rServiceContext)
>>>
>>> How can I get the session from this?  Thanks
>>> Patrick
>>>     
>>
>>   
> 



Re: How to get a session from a service?

Posted by Scott Gray <sc...@hotwaxmedia.com>.
You can't, services are isolated and not aware of the http request/response cycle.  You need to explicitly pass in any parameters that the service will use.

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 9/03/2010, at 8:08 AM, Patrick wrote:

> I have a service definition
> public static Map<String, Object> sendMailFromScreen(DispatchContext
> dctx, Map<String, ? extends Object> rServiceContext)
> 
> How can I get the session from this?  Thanks
> Patrick