ArcGIS Blog

Developers

ArcGIS Enterprise

Extend hosted feature services in ArcGIS Enterprise through service interceptors

By Aawaj Joshi

Have you grown frustrated that you can’t intercept and modify requests and responses in hosted feature services to automate data filtering, enrichment, and validation? If so, you’re in luck because you’ll soon be able to do just that and more through service interceptors.

At this year’s Developer and Technology Summit plenary, Pankaj Chaudhari offers a glimpse of what can be accomplished with service interceptors.

For his demonstration, Pankaj has built an incident reporting app where users can report non-emergency issues such as noise or sanitation problems and infrastructure damage. The data submitted by users are stored in a hosted feature service.

Pankaj's incident reporting app for reporting non-emergency issues.
Pankaj's incident reporting app for reporting non-emergency issues.

As is, the app stores data without any backend validation or enrichment when he creates a new incident report by defining only the incident and location types.

A new incident report containing very little information.
A new incident report containing very little information.

To extend the app with automatic data validation and incident assignment capabilities, Pankaj has created a service interceptor using the ArcGIS Enterprise SDK.

The program, which is written in Java, begins with an Interceptor annotation that provides data about the interceptor, including its name, description, and the URL pattern of the associated hosted feature service.

The Interceptor annotation that provides data about the interceptor.
The Interceptor annotation that provides data about the interceptor.

The key method in his program is the intercept method, which is executed each time a new report is submitted or a response is sent back to the client.

The method contains custom logic to intercept each incoming request and perform the following tasks:

  • If the report provides a location, check if it is within city boundaries.
  • If address details are missing, use reverse geocoding to determine the details and add them to the report.
  • Based on the type of incident, create a ticket containing the incident ID in the appropriate agency’s ServiceNow system.

Additionally, the method contains the logic to intercept each outgoing response and attach the most recent incident status to it before it’s sent back to the client.

The intercept method contains custom logic to intercept and modify each incoming request and outgoing response.
The intercept method contains custom logic to intercept and modify each incoming request and outgoing response.

Pankaj has packaged the project into a .interceptor file, which needs to be deployed to ArcGIS Server. To do so, he uploads the file and registers it with ArcGIS Server using ArcGIS Server Administrator Directory, and within seconds, the service interceptor is ready for use.

The service interceptor is deployed to ArcGIS Server.
The service interceptor is deployed to ArcGIS Server.

To show the service interceptor in action, he reopens the incident reporting app and submits a new report by defining only the incident and location types. He clicks the incident feature on the map to view its details, which the service interceptor has automatically populated to include the address, a unique incident ID, the agency assigned to it, and status.

The service interceptor intercepts and populates the missing data in the incident report.
The service interceptor intercepts and populates the missing data in the incident report.

Next, he updates the incident’s status on the agency’s ServiceNow system, which triggers the service interceptor to update its status on the app.

The service interceptor intercepts the outgoing response and updates the incident's status on the app.
The service interceptor intercepts the outgoing response and updates the incident's status on the app.

While Pankaj worked with a hosted feature service in his demonstration, service interceptors can be used to intercept and modify requests and responses in any type of service published to ArcGIS Enterprise. It’s what makes service interceptors a truly powerful tool for automating workflows, enforcing business rules, and enriching responses in real time. Stay tuned for more information and communication about this ongoing project.

Share this article