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
@ServerObjectExtProperties(displayName = "Simple SOI (Map Service - Pro)", description = "This is a simple SOI for a map service published from ArcGIS Pro.", interceptor = true, servicetype = "MapService")
public class MySimpleSOI
implements IServerObjectExtension, IRESTRequestHandler, IWebRequestHandler, IRequestHandler2, IRequestHandler {
private static final long serialVersionUID = 1L;
private static final String ARCGISHOME_ENV = "AGSSERVER";
private ILog serverLog;
private IServerObject so;
private SOIHelper soiHelper;
/**
* Default constructor.
*
* @throws Exception
*/
public MySimpleSOI() throws Exception {
super();
}
/**
* 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
*/
public void init(IServerObjectHelper soh) throws IOException, AutomationException {
/*
* 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.
*/
// Get reference to server logger utility
this.serverLog = ServerUtilities.getServerLogger();
// Log message with server
this.serverLog.addMessage(3, 200, "Initialized " + this.getClass().getName() + " SOI.");
this.so = soh.getServerObject();
String arcgisHome = getArcGISHomeDir();
/* If null, throw an exception */
if (arcgisHome == null) {
serverLog.addMessage(1, 200, "Could not get ArcGIS home directory. Check if environment variable "
+ ARCGISHOME_ENV + " is set.");
throw new IOException("Could not get ArcGIS home directory. Check if environment variable " + ARCGISHOME_ENV
+ " is set.");
}
if (arcgisHome != null && !arcgisHome.endsWith(File.separator))
arcgisHome += File.separator;
// Load the SOI helper.
this.soiHelper = new SOIHelper(arcgisHome + "XmlSchema" + File.separator + "MapServer.wsdl");
}
/**
* 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
*/
@Override
public byte[] handleRESTRequest(String capabilities, String resourceName, String operationName,
String operationInput, String outputFormat, String requestProperties, String[] responseProperties)
throws IOException, AutomationException {
/*
* 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.
*/
/*
* Log message with server.
*/
serverLog.addMessage(3, 200, "Request received in MySimple SOI for handleRESTRequest");
serverLog.addMessage(3, 200, "capabilities - " + capabilities);
serverLog.addMessage(3, 200, "resourceName - " + resourceName);
serverLog.addMessage(3, 200, "operationName - " + operationName);
serverLog.addMessage(3, 200, "operationInput - " + operationInput);
serverLog.addMessage(3, 200, "outputFormat - " + outputFormat);
serverLog.addMessage(3, 200, "requestProperties - " + requestProperties);
serverLog.addMessage(3, 200, "Sleeping");
try {
Thread.sleep(3000L);
}catch(Exception exc) {
//ignored
serverLog.addMessage(3, 200, "We got an error when trying to sleep");
}
serverLog.addMessage(3, 200, "Done Sleeping");
/*
* Add code to manipulate REST requests here
*/
// Find the correct delegate to forward the request too
IRESTRequestHandler restRequestHandler = soiHelper.findRestRequestHandlerDelegate(so);
if (restRequestHandler != null) {
// Return the response
return restRequestHandler.handleRESTRequest(capabilities, resourceName, operationName, operationInput,
outputFormat, requestProperties, responseProperties);
}
return null;
}
}