How to get a session from a service?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get a session from a service?

Patrick-4
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
Reply | Threaded
Open this post in threaded view
|

Re: How to get a session from a service?

Scott Gray-2
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


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to get a session from a service?

Ruth Hoffman-2
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"
[hidden email]


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
>>    
>
>  
Reply | Threaded
Open this post in threaded view
|

Re: How to get a session from a service?

Scott Gray-2
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"
> [hidden email]
>
>
> 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
>>>    
>>
>>  


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to get a session from a service?

BJ Freeman
In reply to this post by Scott Gray-2
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"
> [hidden email]
>
>
> 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
>>>    
>>
>>  
>