How to set Content-Type of SOE REST Web Service in Java

2592
2
01-12-2012 03:27 AM
ThorstenDeelmann
New Contributor
Hi,

since I didn't find anything helpful, I will post my question here.

I developed a SOE REST Web Service with the Java AcrObjects SDK. For a specific operation I want to return a XML document and for another operation an image.

In another Thread (http://forums.arcgis.com/threads/7993-SOE-REST-Web-Service-How-to-return-different-MIME-content-type...) I read that this is possible by setting the responseProperties parameter of the handleRestRequest method of the IRESTRequestHandler interface. So I tried to set it the following way before returning the byte array:

responseProperties = new String[]{"{\"Content-Type\" : \"text/xml\"}"};


Unfortunately this has no effect on the response content type, which is still text/plain.

Is there anything wrong with this approach or did I miss something?

Any help or working examples would be very much appreciated.

Thanks,
Thorsten
0 Kudos
2 Replies
PauliusUrbonas
New Contributor
Hi there,
this is quite an old post but maybe it will be useful to someone. I worked on returning files from the SOE and figured out that
you have to set response properties to java.util.Map responseProperties before returning bytes array and then it should work:
responseProperties.put("Content-Type", "text/xml");

It worked for me.
0 Kudos
TomSchuller
Occasional Contributor III
Hy,
just to reopen the discussion.
How can I define the content-type in a Java-Rest-SOE?

I have this method:
 public byte[] handleRESTRequest(String capabilities, String resourceName, String operationName, String operationInput, String outputFormat, String requestProperties, String[] responseProperties) throws IOException {


So the "responseProperties" is an array of String.
In the last post, this should solve the problem:
Map<String,String> responsePropertiesMap = new HashMap<String, String>();responsePropertiesMap.put("Content-Type", "text/xml");


How can I return the "responsePropertiesMap" in your example?
Something like this doesn't work:
  responseProperties[0]=responsePropertiesMap:

Just found it now:
This is a solution I got it working:
JSONObject contentType = new JSONObject();
contentType.put("Content-Type", "text/xml");
responseProperties[0] = contentType.toString();


Tom
0 Kudos