I am attempting to write my first SOI and I am running into a problem, not all of my REST requests are being intercepted on my FeatureService I added the .soe extention too. I am wanting to intercept every call made to my published feature service, and log out all of the REST Request information to the server. I loaded the Simple SOI example from the ArcGIS Enterprise SDK Installation directory to get started and just modified the handleRESTRequest method.
After I disabledCaching on my featureService from ArcGIS Server Administrator Directory, more calls are being intercepted, but not all.
Can anyone see anything incorrect with my setup in my code? Should I set disableCaching=true on my FeatureService for this to work?
Calls that were intercepted once:
https://myserver:portNumber/arcgis/rest/services/myFeatureService/FeatureServer?f=json
Calls that did not work before disablingCaching was set to true:
https://myserver:portNumber/arcgis/rest/services/myFeatureService/FeatureServer/1?f=json (getting layer definition)
ArcGIS Server 10.7.1
Feature Services are published from ArcGIS Pro
Written in Java
See Code below (I omitted the other overridden methods):
@ArcGISExtension
@<SPAN class="token function">ServerObjectExtProperties</SPAN><SPAN class="punctuation token">(</SPAN>displayName <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Simple SOI (Map Service - Pro)"</SPAN><SPAN class="punctuation token">,</SPAN> description <SPAN class="operator token">=</SPAN> <SPAN class="string token">"This is a simple SOI for a map service published from ArcGIS Pro."</SPAN><SPAN class="punctuation token">,</SPAN> interceptor <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">true</SPAN><SPAN class="punctuation token">,</SPAN> servicetype <SPAN class="operator token">=</SPAN> <SPAN class="string token">"MapService"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">class</SPAN> <SPAN class="token class-name">MySimpleSOI</SPAN>
<SPAN class="keyword token">implements</SPAN> <SPAN class="token class-name">IServerObjectExtension</SPAN><SPAN class="punctuation token">,</SPAN> IRESTRequestHandler<SPAN class="punctuation token">,</SPAN> IWebRequestHandler<SPAN class="punctuation token">,</SPAN> IRequestHandler2<SPAN class="punctuation token">,</SPAN> IRequestHandler <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">static</SPAN> <SPAN class="keyword token">final</SPAN> <SPAN class="keyword token">long</SPAN> serialVersionUID <SPAN class="operator token">=</SPAN> 1L<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">static</SPAN> <SPAN class="keyword token">final</SPAN> String ARCGISHOME_ENV <SPAN class="operator token">=</SPAN> <SPAN class="string token">"AGSSERVER"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">private</SPAN> ILog serverLog<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">private</SPAN> IServerObject so<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">private</SPAN> SOIHelper soiHelper<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">/**
* Default constructor.
*
* @throws Exception
*/</SPAN>
<SPAN class="keyword token">public</SPAN> <SPAN class="token function">MySimpleSOI</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">throws</SPAN> Exception <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">super</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token">/**
* init() is called once, when the instance of the SOE/SOI is created.
*
* @param soh the IServerObjectHelper
* @throws IOException Signals that an I/O exception has occurred.
* @throws AutomationException the automation exception
*/</SPAN>
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">init</SPAN><SPAN class="punctuation token">(</SPAN>IServerObjectHelper soh<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">throws</SPAN> IOException<SPAN class="punctuation token">,</SPAN> AutomationException <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">/*
* An SOE should retrieve a weak reference to the Server Object from the Server Object Helper in
* order to make any method calls on the Server Object and release the reference after making
* the method calls.
*/</SPAN>
<SPAN class="comment token">// Get reference to server logger utility</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>serverLog <SPAN class="operator token">=</SPAN> ServerUtilities<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getServerLogger</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Log message with server</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Initialized "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">getClass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">getName</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" SOI."</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>so <SPAN class="operator token">=</SPAN> soh<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getServerObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
String arcgisHome <SPAN class="operator token">=</SPAN> <SPAN class="token function">getArcGISHomeDir</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">/* If null, throw an exception */</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>arcgisHome <SPAN class="operator token">==</SPAN> null<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Could not get ArcGIS home directory. Check if environment variable "</SPAN>
<SPAN class="operator token">+</SPAN> ARCGISHOME_ENV <SPAN class="operator token">+</SPAN> <SPAN class="string token">" is set."</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">throw</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">IOException</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Could not get ArcGIS home directory. Check if environment variable "</SPAN> <SPAN class="operator token">+</SPAN> ARCGISHOME_ENV
<SPAN class="operator token">+</SPAN> <SPAN class="string token">" is set."</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>arcgisHome <SPAN class="operator token">!=</SPAN> null <SPAN class="operator token">&&</SPAN> <SPAN class="operator token">!</SPAN>arcgisHome<SPAN class="punctuation token">.</SPAN><SPAN class="token function">endsWith</SPAN><SPAN class="punctuation token">(</SPAN>File<SPAN class="punctuation token">.</SPAN>separator<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcgisHome <SPAN class="operator token">+=</SPAN> File<SPAN class="punctuation token">.</SPAN>separator<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Load the SOI helper. </SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>soiHelper <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">SOIHelper</SPAN><SPAN class="punctuation token">(</SPAN>arcgisHome <SPAN class="operator token">+</SPAN> <SPAN class="string token">"XmlSchema"</SPAN> <SPAN class="operator token">+</SPAN> File<SPAN class="punctuation token">.</SPAN>separator <SPAN class="operator token">+</SPAN> <SPAN class="string token">"MapServer.wsdl"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token">/**
* This method is called to handle REST requests.
*
* @param capabilities the capabilities
* @param resourceName the resource name
* @param operationName the operation name
* @param operationInput the operation input
* @param outputFormat the output format
* @param requestProperties the request properties
* @param responseProperties the response properties
* @return the response as byte[]
* @throws IOException Signals that an I/O exception has occurred.
* @throws AutomationException the automation exception
*/</SPAN>
@Override
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">byte</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="token function">handleRESTRequest</SPAN><SPAN class="punctuation token">(</SPAN>String capabilities<SPAN class="punctuation token">,</SPAN> String resourceName<SPAN class="punctuation token">,</SPAN> String operationName<SPAN class="punctuation token">,</SPAN>
String operationInput<SPAN class="punctuation token">,</SPAN> String outputFormat<SPAN class="punctuation token">,</SPAN> String requestProperties<SPAN class="punctuation token">,</SPAN> String<SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> responseProperties<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">throws</SPAN> IOException<SPAN class="punctuation token">,</SPAN> AutomationException <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">/*
* Log message with server. Here we are logging who made the request,
* what operation was invoked and with what input parameters.
*
* You can use different log codes to set up different log levels.
*
* For example:
* Use log code 1 for Severe Messages.
* Use log code 2 for Warning Messages.
* Use log code 3 for Info Messages.
* Use log code 4 for Fine Messages.
* Use log code 100 for Debug Messages.
*
* Note: You can also use the ILog interface to get more information on log message levels.
*/</SPAN>
<SPAN class="comment token">/*
* Log message with server.
*/</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Request received in MySimple SOI for handleRESTRequest"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"capabilities - "</SPAN> <SPAN class="operator token">+</SPAN> capabilities<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"resourceName - "</SPAN> <SPAN class="operator token">+</SPAN> resourceName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"operationName - "</SPAN> <SPAN class="operator token">+</SPAN> operationName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"operationInput - "</SPAN> <SPAN class="operator token">+</SPAN> operationInput<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"outputFormat - "</SPAN> <SPAN class="operator token">+</SPAN> outputFormat<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"requestProperties - "</SPAN> <SPAN class="operator token">+</SPAN> requestProperties<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Sleeping"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">try</SPAN> <SPAN class="punctuation token">{</SPAN>
Thread<SPAN class="punctuation token">.</SPAN><SPAN class="token function">sleep</SPAN><SPAN class="punctuation token">(</SPAN>3000L<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="keyword token">catch</SPAN><SPAN class="punctuation token">(</SPAN>Exception exc<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//ignored</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"We got an error when trying to sleep"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
serverLog<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addMessage</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Done Sleeping"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">/*
* Add code to manipulate REST requests here
*/</SPAN>
<SPAN class="comment token">// Find the correct delegate to forward the request too</SPAN>
IRESTRequestHandler restRequestHandler <SPAN class="operator token">=</SPAN> soiHelper<SPAN class="punctuation token">.</SPAN><SPAN class="token function">findRestRequestHandlerDelegate</SPAN><SPAN class="punctuation token">(</SPAN>so<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>restRequestHandler <SPAN class="operator token">!=</SPAN> null<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Return the response</SPAN>
<SPAN class="keyword token">return</SPAN> restRequestHandler<SPAN class="punctuation token">.</SPAN><SPAN class="token function">handleRESTRequest</SPAN><SPAN class="punctuation token">(</SPAN>capabilities<SPAN class="punctuation token">,</SPAN> resourceName<SPAN class="punctuation token">,</SPAN> operationName<SPAN class="punctuation token">,</SPAN> operationInput<SPAN class="punctuation token">,</SPAN>
outputFormat<SPAN class="punctuation token">,</SPAN> requestProperties<SPAN class="punctuation token">,</SPAN> responseProperties<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">return</SPAN> null<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>