Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

Thanks for any suggestions.

share|improve this question
    
Why do you need the full url? –  Jamie Mar 13 '13 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 '13 at 19:40
add comment

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);
        else
            result.AddString("filepath", "null filepath");
    }
    else
        result.AddString("filepath", "no svrInit");
    return Encoding.UTF8.GetBytes(result.ToJson());
}
share|improve this answer
    
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 '13 at 19:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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