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:
| Interface | Description |
|---|---|
IREST | Handles REST requests and provides access to REST resource and operation information. |
I and I | Handle SOAP string requests and supported binary requests. |
I | Handles 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 IREST interface enables an SOI to intercept REST requests and customize service operations.
The interface provides two methods:
handle— Processes incoming REST requests and returns responses.REST Request() get— Returns the REST resource and operation schema.Schema()
handleRESTRequest()
The handle method provides access to the request information, including the requested resource, operation, input parameters, output format, and request properties.
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:
| Parameter | Description |
|---|---|
capabilities | Specifies the capabilities associated with the request. |
resource | Identifies the requested REST resource. |
operation | Identifies the requested operation, such as export, identify, or query. |
operation | Contains the operation input parameters, typically represented as JSON. |
output | Specifies the requested output format. |
request | Contains additional request properties and metadata. |
response | Allows 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 get method returns the REST schema describing available resources and operations.
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 I interface extends I and supports handling binary requests and SOAP requests.
These interfaces provide the following methods:
handle— Processes binary requests with explicit capabilities.Binary Request2() handle— Processes binary requests.Binary Request() handle— Processes SOAP requests represented as XML strings.String Request()
handleBinaryRequest2()
The handle method receives binary requests and returns binary responses.
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 handle method, inherited from I, processes SOAP requests represented as XML strings.
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 I 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 handle method.
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:
| Parameter | Description |
|---|---|
http | Specifies the HTTP method used for the request. |
request | Contains the request URL. |
query | Contains the request query parameters. |
capabilities | Specifies the capabilities associated with the request. |
request | Contains the request body, when applicable. |
response | Specifies the response content type through a string array. |
resp | Specifies how the response data should be interpreted, using values from esri. |
An SOI can inspect incoming parameters, apply custom logic, and delegate requests to the underlying service.
The response and resp 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 SOI 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:
find— Retrieves the underlying REST request handler.Rest Request Handler Delegate() find— Retrieves the underlying request handler.Request Handler Delegate() find— Retrieves the underlying binary request handler.Request Handler2 Delegate() find— Retrieves the underlying web request handler.Web Request Handler Delegate() convert— Converts a binary request into an SDK message object.Binary Request To Message() convert— Converts a SOAP string request into an SDK message object.String Request To Message() convert— Converts a message object into a binary request.Message To Binary Request() convert— Converts a message object into a SOAP string request.Message To 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 SOI, call soi during the extension's shutdown() method to release helper resources, particularly when working with shared instances.
For example:
@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.