Is it possible to access HttpContext inside SOE?

4495
11
07-19-2012 04:18 PM
YanyiZhang
New Contributor
Hi guys,
    I'm wondering is it possible to access cookies or session from Httpcontext inside SOE?
    Thanks.
Tags (2)
0 Kudos
11 Replies
YanyiZhang
New Contributor
And can we handle Session_End event by any chance?
0 Kudos
RichardWatson
Frequent Contributor
I'd be shocked if this were possible.  The interface to SOE's is very limited.

If you want this type of information then I think that you have to take care of this yourself.

For example, we do something similar by providing our own ASP.NET web application which all REST (and other) end points have to go through.  The web application serves as a proxy, adds custom business logic, etc.  It is also able to add information (using URL arguments) to the REST calls.
0 Kudos
AjitDharmik
New Contributor III
feng0hua0,

SOEs at 10.1 do not have access to the HTTPContext of incoming request. The REST/Web Services handler intercepts all requests to SOEs and allows only pre-defined ArcGIS specific request information pieces in, such as query params.

Could you share more info about what you are trying to accomplish and require the http context inside SOEs for?

Thanks!
Ajit
0 Kudos
YanyiZhang
New Contributor
feng0hua0,

SOEs at 10.1 do not have access to the HTTPContext of incoming request. The REST/Web Services handler intercepts all requests to SOEs and allows only pre-defined ArcGIS specific request information pieces in, such as query params.

Could you share more info about what you are trying to accomplish and require the http context inside SOEs for?

Thanks!
Ajit


Yes, sure. First, we do need to retrieve Post/Get params from client side and server side will processing data base on these params. Second, we will cache some user resources in our server business table and we will compile statistics after users end their sessions. In that case, we may need Session_End event. What't more, we use SessionID which from HttpContext to identify a user in Session_End processing.

Thanks!
0 Kudos
AjitDharmik
New Contributor III
I apologize for the very late response.

>> Second, we will cache some user resources in our server business table and we will compile statistics after users end their sessions. In that case, we may need Session_End event. What't more, we use SessionID which from HttpContext to identify a user in Session_End processing. >>

One can always access any database from inside SOEs to store info. However, HTTPContext info is not currently available to SOEs (at 10.1). Its not planned to be supported at 10.2 either.

However, you have access to user name from inside SOEs and if the SOE client shares a session id and session status with the SOE, you could implement this behavior.

Following is a code snippet to retrieve user name:

EnvironmentManager envMgr = new EnvironmentManager();
  
UID envUID = new UID();
envUID.setValue("{32d4c328-e473-4615-922c-63c108f55e60}");
Object envObj = envMgr.getEnvironment(envUID);

IServerEnvironment2 env2 = new IServerEnvironment2Proxy(envObj);
IServerUserInfo userInfo = env2.getUserInfo();

Hope this helps.
Ajit
0 Kudos
PetrDiviš
New Contributor III

HI Ajit

do you know by any chance how to get more information from the AGS about the User or Roles?

I need Role's title to work with it, not role ID. I found that there is some method ESRI.ArcGIS.Server.IRoleStore.GetRolesForUser() or other methods on that inteface. But I have no clue how to get hold of that instance in my SOE.

Thanks for any help!

Petr

0 Kudos
LorenzMeyer1
Occasional Contributor

Hi

Did you found an answer to this question? How to get access to the interface IRoleStore? There's no documentation on how to get it and no CoClass. 

thanks

0 Kudos
nicogis
MVP Frequent Contributor

you can get user and roles from soe :

http://support.esri.com/technical-article%5C000011331

0 Kudos
LorenzMeyer1
Occasional Contributor

Hi Domenico

Thanks for the link, but this does not solve my Problem. I know how to return my logged in user and roles, but how can I get Access to the Interface IRoleStore to get all users and all roles to some user?

Cheers

0 Kudos