This topic provides an overview of developing server object interceptors (SOIs) using the ArcGIS Enterprise SDK for Java. It describes the interfaces used to intercept REST, SOAP, and OGC requests, as well as the utilities available for processing requests and responses.

Intercept REST, SOAP, and OGC service requests

SOIs allow developers to intercept and customize requests and responses for existing operations of ArcGIS Server map and image services, including supported service extensions such as feature services.

Depending on the service type and configuration, an SOI can handle the following request types:

  • REST requests: Requests made through ArcGIS REST API endpoints.
  • SOAP requests: Requests made through SOAP service interfaces.
  • OGC requests: Requests made through supported Open Geospatial Consortium (OGC) interfaces, such as Web Map Service (WMS) and Web Feature Service (WFS).

The ArcGIS Enterprise SDK provides the following interfaces for handling these requests:

InterfaceDescription
IRESTRequestHandlerHandles REST requests and provides access to REST resource and operation information.
IRequestHandler and IRequestHandler2Handle SOAP string requests and supported binary requests.
IWebRequestHandlerHandles supported web requests, including OGC and KML requests.

These interfaces are defined in the com.esri.arcgis.system package.

When an SOI is enabled on a service, ArcGIS Server routes supported requests through the SOI. The SOI can inspect or modify an incoming request, delegate it to the underlying service, and process the response before returning it to the client.

When developing an SOI, consider the following approaches:

  • Security-related SOIs: Implement and validate all applicable request handlers to ensure that access restrictions are enforced consistently. Start by denying requests and explicitly allowing only those that satisfy the required authorization conditions.
  • Non-security SOIs: Begin by delegating requests to the underlying service without modification. Then add custom logic for the operations that require customization.

Implement the IRESTRequestHandler interface

The IRESTRequestHandler interface enables an SOI to intercept REST requests and customize service operations.

The interface provides two methods:

  • handleRESTRequest() — Processes incoming REST requests and returns responses.
  • getSchema() — Returns the REST resource and operation schema.

handleRESTRequest()

The handleRESTRequest() method provides access to the request information, including the requested resource, operation, input parameters, output format, and request properties.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
public byte[] handleRESTRequest(
    String capabilities,
    String resourceName,
    String operationName,
    String operationInput,
    String outputFormat,
    String requestProperties,
    String[] responseProperties
) throws IOException, AutomationException;

The following table describes its parameters:

ParameterDescription
capabilitiesSpecifies the capabilities associated with the request.
resourceNameIdentifies the requested REST resource.
operationNameIdentifies the requested operation, such as export, identify, or query.
operationInputContains the operation input parameters, typically represented as JSON.
outputFormatSpecifies the requested output format.
requestPropertiesContains additional request properties and metadata.
responsePropertiesAllows the SOI to provide response properties through a string array.

An SOI can examine and modify request parameters before delegating the request to the underlying service. After the service processes the request, the SOI can inspect or modify the returned response.

For example, an SOI can modify the input parameters for a map service's export operation or filter attributes from a feature service's query response.

getSchema()

The getSchema() method returns the REST schema describing available resources and operations.

Use dark colors for code blocksCopy
1
2
public String getSchema()
    throws IOException, AutomationException;

Typically, the SOI delegates this method to the underlying service and returns its schema. Developers can customize the schema when required by their implementation.

The schema is used by REST clients and the ArcGIS Server Services Directory to discover available resources and operations.

For implementation examples, see Handle REST requests and responses in SOIs.

Implement the IRequestHandler2 interface

The IRequestHandler2 interface extends IRequestHandler and supports handling binary requests and SOAP requests.

These interfaces provide the following methods:

  • handleBinaryRequest2() — Processes binary requests with explicit capabilities.
  • handleBinaryRequest() — Processes binary requests.
  • handleStringRequest() — Processes SOAP requests represented as XML strings.

handleBinaryRequest2()

The handleBinaryRequest2() method receives binary requests and returns binary responses.

Use dark colors for code blocksCopy
1
2
3
4
public byte[] handleBinaryRequest2(
    String capabilities,
    byte[] request
) throws IOException, AutomationException;

The request parameter contains the binary request data.

An SOI can use the ArcGIS Enterprise SDK utilities to deserialize supported requests, inspect or modify their contents, and serialize the modified requests before delegating them to the underlying service.

Binary request handling is primarily relevant to legacy ArcObjects-based clients and other supported binary request workflows.

handleStringRequest()

The handleStringRequest() method, inherited from IRequestHandler, processes SOAP requests represented as XML strings.

Use dark colors for code blocksCopy
1
2
3
4
public String handleStringRequest(
    String capabilities,
    String request
) throws IOException, AutomationException;

An SOI can inspect or modify the XML request before forwarding it to the underlying service. It can also process the SOAP response before returning it to the client.

The ArcGIS Enterprise SDK provides supporting utilities for converting and processing SOAP request and response objects.

For implementation examples, see Handle SOAP requests and responses in SOIs.

Implement the IWebRequestHandler interface

The IWebRequestHandler interface enables an SOI to intercept supported web requests, including OGC requests such as WMS and WFS, when supported and enabled by the underlying service.

The interface provides the handleStringWebRequest() method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
public byte[] handleStringWebRequest(
    int httpMethod,
    String requestURL,
    String queryString,
    String capabilities,
    String requestData,
    String[] responseContentType,
    int[] respDataType
) throws IOException, AutomationException;

The following table describes its parameters:

ParameterDescription
httpMethodSpecifies the HTTP method used for the request.
requestURLContains the request URL.
queryStringContains the request query parameters.
capabilitiesSpecifies the capabilities associated with the request.
requestDataContains the request body, when applicable.
responseContentTypeSpecifies the response content type through a string array.
respDataTypeSpecifies how the response data should be interpreted, using values from esriWebResponseDataType.

An SOI can inspect incoming parameters, apply custom logic, and delegate requests to the underlying service.

The responseContentType and respDataType parameters determine how ArcGIS Server handles the returned response content.

Utilities for processing requests and responses

The ArcGIS Enterprise SDK provides utility classes to simplify Java SOI development.

The SOIHelper class in the com.esri.arcgis.server package provides methods for delegating requests to underlying service handlers and converting supported SOAP and binary request representations.

These utilities include:

  • findRestRequestHandlerDelegate() — Retrieves the underlying REST request handler.
  • findRequestHandlerDelegate() — Retrieves the underlying request handler.
  • findRequestHandler2Delegate() — Retrieves the underlying binary request handler.
  • findWebRequestHandlerDelegate() — Retrieves the underlying web request handler.
  • convertBinaryRequestToMessage() — Converts a binary request into an SDK message object.
  • convertStringRequestToMessage() — Converts a SOAP string request into an SDK message object.
  • convertMessageToBinaryRequest() — Converts a message object into a binary request.
  • convertMessageToStringRequest() — Converts a message object into a SOAP string request.

For examples of request delegation and SOAP or binary request processing, see the Layer Access SOI sample.

SOI resource cleanup

For Java SOIs that use SOIHelper, call soiHelper.cleanup() during the extension's shutdown() method to release helper resources, particularly when working with shared instances.

For example:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
@Override
public void shutdown()
        throws IOException, AutomationException {
    if (soiHelper != null) {
        soiHelper.cleanup();
        soiHelper = null;
    }
}

The cleanup() method releases resources associated with the helper. It does not force Java garbage collection.

Development considerations

When developing Java SOIs, consider the following recommendations:

  • Request handling: Implement the applicable REST, SOAP, and OGC interfaces based on the service configuration and intended functionality.
  • Security: Validate authorization requirements across all supported operations and request paths.
  • Performance: Minimize unnecessary processing in request handlers, especially when intercepting frequently used service operations.
  • Error handling: Handle invalid requests, unsupported operations, and delegation failures appropriately.
  • Logging: Use ArcGIS Server logging utilities to record relevant diagnostic information without exposing sensitive data.
  • Resource management: Release native references and helper resources when they are no longer needed.
  • Testing: Verify request preprocessing, response postprocessing, and delegation against the target ArcGIS Server version and supported service configurations.

Also See

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.