0

I would like to obtain the full URL of a REST request inside of an ArcGIS Server SOE.

I would like to return the full URL to an output file. But, the service may be exposed on different servers or through different urls on the same server via a proxy.

I'm working with ArcGIS Server 10.1 on Windows with IIS.

  • I couldn't understand second question correctly. Could you explain more infomation? – Darksanta May 17 '13 at 11:12
  • I was just trying to explain why I can't hard code the host portion of the URL. The service will be deployed to different servers with different URLs. Some of the servers have a different URL when accessed externally. In that case the request goes through a proxy server, so the server has no knowledge of its own URL, which rules out getting the host portion of the URL from a server property. So getting it from the request seems like the best option. – Preston May 17 '13 at 16:20
1

I did find a solution for this. A property set of server environment information can be retrieved with the following code:

        EnvironmentManager envMgr = new EnvironmentManager();
        UID envUID = new UID();
        envUID.Value = "{32d4c328-e473-4615-922c-63c108f55e60}";
        object envObj = envMgr.GetEnvironment(envUID);
        IServerEnvironment3 serverEnvironment = (IServerEnvironment3)envObj;
        IPropertySet serverPropsTemp = serverEnvironment.Properties;

There are a number of useful reference paths in the property set that provide the information needed to return absolute URLs instead of relative paths for generated files and other resources.

"AdminTokenURL": "http://REDACTED/arcgis/admin/generateToken",  
"RestURL": "http://REDACTED/arcgis/rest",  
"AdminUser": "REDACTED",  
"SoapURL": "http://REDACTED/arcgis/services",  
"AdminURL": "http://REDACTED/arcgis/admin",  
"AdminUserPassword": "REDACTED",  
"RequestContextURL": "http://REDACTED/arcgis"

Thanks to Ajit for the lead in this ESRI forum thread: http://forums.arcgis.com/threads/62768-Is-it-possible-to-access-HttpContext-inside-SOE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.