Select to view content in your preferred language

ArcGIS REST Services Directory using an SOE

446
3
02-07-2013 08:50 AM
RichardWatson
Deactivated User
I have an SOE which extends the ArcGIS Server map services.  The SOE itself works well, i.e. I can call the various functions with no problem.  The issue I have is using the ArcGIS Services Directory in order to explore my SOE.

In particular, I have Child Resources off my root resource which are not collections but do have child resources.  The resource is sort of like a folder which contains other folders.  Here is an portion of the schema:

{
    "name": "NE",
    "isCollection": false,
    "resources": [{
        "name": "Inventory",
        "isCollection": false,
        "operations": [{
// Text omitted
}

When I click on Inventory in the REST Services Directory what the code returns is a response which is application/json where the content is "{}".  What the browser then does is to issue the following prompt "Do you want to open or save Inventory.json (2 bytes) from localhost?".  The browser I am using is IE 10 on Windows 8 x64.

What am I doing wrong?  I believe that this code used to work in version 10 but I am currently running 10.1 SP1.
Tags (2)
0 Kudos
3 Replies
nicogis
MVP Alum
have you tried set in your rootresourcehandler?


responseProperties = "{\"Content-Type\" : \"application/json\"}";

0 Kudos
RichardWatson
Deactivated User
I looked at the response in Fiddler and it is application/json.

I think that I need to write a sample program and see if I can reproduce this behavior.

I was hoping to avoid having to do that:(
0 Kudos
RichardWatson
Deactivated User
I figured out what is going on and how to "fix" the problem.  I post the answer here in case someone else has this problem in the future.

The last argument to IRESTRequestHandler.HandleRESTRequest is responseProperties which is the response properties in JSON format.

I know of 2 valid members which are Content-Type and ResponseDataType.  The later relates to esriWebResponseDataType.  The former is standard web stuff.

In my case I always return JSON and in this particular case the response is "{}".

If I return null for responseProperties then the REST Services directory works.
If I return "application/json" for Content-Type then the REST Services directory works.
If I return "application/json; charset=UTF-8" for Content-Type then the REST Services directory fails.  This is what the code was doing.

I think that returning charset is valid, should work, and (to the best of my knowledge) used to work in version 10.  That said, it is probably redundant since JSON is always UTF-8.
0 Kudos