<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to set Content-Type of SOE REST Web Service in Java in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-content-type-of-soe-rest-web-service-in/m-p/342187#M8984</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;since I didn't find anything helpful, I will post my question here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In another Thread (&lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/7993-SOE-REST-Web-Service-How-to-return-different-MIME-content-types"&gt;http://forums.arcgis.com/threads/7993-SOE-REST-Web-Service-How-to-return-different-MIME-content-types&lt;/A&gt;&lt;SPAN&gt;) 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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;responseProperties = new String[]{"{\"Content-Type\" : \"text/xml\"}"};&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately this has no effect on the response content type, which is still text/plain.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there anything wrong with this approach or did I miss something?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or working examples would be very much appreciated. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thorsten&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Jan 2012 11:27:59 GMT</pubDate>
    <dc:creator>ThorstenDeelmann</dc:creator>
    <dc:date>2012-01-12T11:27:59Z</dc:date>
    <item>
      <title>How to set Content-Type of SOE REST Web Service in Java</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-content-type-of-soe-rest-web-service-in/m-p/342187#M8984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;since I didn't find anything helpful, I will post my question here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In another Thread (&lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/7993-SOE-REST-Web-Service-How-to-return-different-MIME-content-types"&gt;http://forums.arcgis.com/threads/7993-SOE-REST-Web-Service-How-to-return-different-MIME-content-types&lt;/A&gt;&lt;SPAN&gt;) 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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;responseProperties = new String[]{"{\"Content-Type\" : \"text/xml\"}"};&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately this has no effect on the response content type, which is still text/plain.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there anything wrong with this approach or did I miss something?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or working examples would be very much appreciated. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thorsten&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jan 2012 11:27:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-content-type-of-soe-rest-web-service-in/m-p/342187#M8984</guid>
      <dc:creator>ThorstenDeelmann</dc:creator>
      <dc:date>2012-01-12T11:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to set Content-Type of SOE REST Web Service in Java</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-content-type-of-soe-rest-web-service-in/m-p/342188#M8985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;you have to set response properties to java.util.Map responseProperties before returning bytes array and then it should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;responseProperties.put("Content-Type", "text/xml");&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;It worked for me.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 May 2012 12:03:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-content-type-of-soe-rest-web-service-in/m-p/342188#M8985</guid>
      <dc:creator>PauliusUrbonas</dc:creator>
      <dc:date>2012-05-09T12:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to set Content-Type of SOE REST Web Service in Java</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-content-type-of-soe-rest-web-service-in/m-p/342189#M8986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;just to reopen the discussion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I define the content-type in a Java-Rest-SOE?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have this method:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; public byte[] handleRESTRequest(String capabilities, String resourceName, String operationName, String operationInput, String outputFormat, String requestProperties, String[] responseProperties) throws IOException {&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the "&lt;/SPAN&gt;&lt;STRONG&gt;responseProperties&lt;/STRONG&gt;&lt;SPAN&gt;" is an array of String.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the last post, this should solve the problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Map&amp;lt;String,String&amp;gt; responsePropertiesMap = new HashMap&amp;lt;String, String&amp;gt;();responsePropertiesMap.put("Content-Type", "text/xml");
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I return the "responsePropertiesMap" in your example?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like this doesn't work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; responseProperties[0]=responsePropertiesMap:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just found it now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;This is a solution I got it working:&lt;BR /&gt;&lt;/STRONG&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;JSONObject contentType = new JSONObject();
contentType.put("Content-Type", "text/xml");
responseProperties[0] = contentType.toString();
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:08:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-set-content-type-of-soe-rest-web-service-in/m-p/342189#M8986</guid>
      <dc:creator>TomSchuller</dc:creator>
      <dc:date>2021-12-11T16:08:42Z</dc:date>
    </item>
  </channel>
</rss>

