I'm having trouble figuring out how to obtain the full url to the map service a Server Object Extension is running on top of. I bascially want:

IMapServer4 mapServer = (IMapServer4)serverObjectHelper.ServerObject;
string fullUrl = mapServer.url 

Which would yield: http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer

Any Ideas?

  • Why do you need the full url?
    – Jamie
    Mar 13, 2013 at 19:39
  • 1
    I felt that the syntax for the dynamicLayers property inside of an export map request was too verbose. Specifically, I'm referring to using a uniqueValueRenderer JSON object. Instead of using symbol1 -> value1, symbol1 -> value2, symbol1 -> value3 - I wanted symbol1 -> [value1, value2, value3]. It turned out that the size of the dynamicLayers object was breaking a portion of the JavaScript API when running from PhoneGap. The Server Object Extension basically supported this more concise JSON syntax, "re-hydrated" into the verbose form, and forwarded back the image response.
    – bcollins
    Mar 20, 2013 at 19:40

1 Answer 1


Here's code that returns the msd path. I don't know of a way to get the original url. (Remember, one or more web adaptors may be used for a service, each with a different hostname). The path to the msd could be parsed and used to construct the portions of the url containing the folder and mapservice name.

For testing I find it helpful to also know the processID, which makes it easier to attach a debugger.

private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, 
    string requestProperties, out string responseProperties)
    responseProperties = null;

    JsonObject result = new JsonObject();            
    var id = System.Diagnostics.Process.GetCurrentProcess().Id;
    result.AddString("Machine", Environment.MachineName);
    result.AddString("ProcessID", id.ToString());
    var svrInit = m_serverObjectHelper.ServerObject as IMapServerInit2;
    if (svrInit != null)
        if (!string.IsNullOrEmpty(svrInit.FilePath))
            result.AddString("filepath", svrInit.FilePath);
            result.AddString("filepath", "null filepath");
        result.AddString("filepath", "no svrInit");
    return Encoding.UTF8.GetBytes(result.ToJson());
  • Hey thanks! This is helpful and thats a good point regarding the use of different web adaptors. With limited time left for development, I simply had the client app send the url with the request. Thanks for your prompt response and I'll post back if I learn anything else on the topic.
    – bcollins
    Mar 20, 2013 at 19:50

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.