Skip to content

Chaining Interceptors Sample

This sample demonstrates how multiple service interceptors interact with a hosted feature service. Each interceptor performs a unique task in the chain, separating the logic into manageable units. This sample uses three interceptors:

  1. Audit log - performs the task of audit logging
  2. Geocoding - fetches the address information based on user input location
  3. System integration - updates the attributes of existing features by integrating with an external system

Supported ArcGIS Enterprise SDK Versions

  • 11.5 Closed Beta; Windows/Linux

Configure the hosted feature service for this sample

Follow the steps below to create a hosted feature service using Portal for ArcGIS.

  1. Download the sample dataset from here.
  2. In Portal for ArcGIS, go to Content > My Content and click the New item button.
  3. Drag or upload incidents.gdb (zipped) to the New item window. Adding the incident.gdb.zip as new item
  4. Under File type, select File geodatabase. Under How would you like to add this file?, select "Add incidents.gdb.zip and create a hosted feature layer". Click the Next button. Set the file type as File geodatabase
  5. Ensure the Title for the hosted feature service is “incidents” and click the Save button. Name the hosted feature service as incidents
  6. Navigate to Content > My Content and click on the incidents hosted feature layer to open the item page. Go to the Settings tab and click Feature layer (hosted) tab.
  7. Make sure to enable the editing capabilities for hosted feature service. Enable the edit in the hosted feature service

Alternatively, you can also create the editing-enabled hosted feature service using ArcGIS Pro.

Download the sample code

Deploy the Interceptors

Deploying the interceptor is done in two parts: uploading and registering.

Upload and Register

After downloading the three interceptor samples, follow the steps below for each of the three interceptor samples.

  1. Unzip the sample into a location of your choosing.
  2. In a web browser, navigate to the ArcGIS Server Administrator Directory and sign in as an administrator.
  3. Click uploads > upload.
  4. On the Upload Item page, click the Choose File button and select the <sample name>.interceptor file located in the <sample name>/target folder in the directory where you unzipped the sample in Step 1 above.
  5. Click the Upload button. Once the file is uploaded, you will be directed to the Uploaded Item page. Copy the Item ID.
  6. Browse to Home > system.
  7. If you do not see a navigation link to interceptors on the page, append /interceptors to the URL in the browser, i.e., <domain>/<server-web-adaptor>/admin/system/interceptors.
  8. Click the register link and paste the value of the Item ID from Step 5 above into the input box. Click the Register button.

Manage the Chaining Order

The business rules for this sample require audit logging for each request, updating address information for newly created incidents based on the input location, and synchronizing other business details, such as incident ID, agency name, and others, from third-party or external systems.

Follow the steps below to set the correct chaining order.

  1. Navigate to <domain>/<server-web-adaptor>/admin/system/interceptors/chainingorder.
  2. In the Chaining Order input box, update the chaining order to match what is shown below:
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    [
        {
            "interceptorName": "AuditLogInterceptor",
            "chainingOrder": 1,
            "urlPatterns": ["/services"]
        },
        {
            "interceptorName": "Geocoding",
            "chainingOrder": 2,
            "urlPatterns": ["/Hosted/incidents"]
        },
        {
            "interceptorName": "SystemIntegration",
            "chainingOrder": 3,
            "urlPatterns": ["/Hosted/incidents"]
        }
    ]

Verify the results

Once all three interceptors are registered, they are functioning immediately. Make sure you have updated the chaining order exactly as shown above.

To inspect the behavior of the audit log interceptor, follow the steps below.

  1. In ArcGIS Server Administrative Directory, navigate to Home > logs > settings > edit. Set the Log Level to INFO and leave all other settings in their default state.
  2. Navigate to <domain>/<server-web-adaptor>/rest/services/Hosted.
  3. Perform a query operation on the incidents hosted feature layer.
  4. In ArcGIS Server Administrative Directory, navigate to Home > logs > query. Set the Level to INFO. Leave all other settings in their default value and click the Query button.

In the log query results, logs that are generated by service interceptors will a have a value of "Enterprise Interceptor" in the Target column. You should see an INFO level log with the Message: "User XXXX accessed the service Hosted/incidents.FeatureServer. Performed the operation - query." Log Info in ArcGIS Server admin

To inspect the behavior of the geocoding and system integration interceptors, follow steps below.

  1. Add the incidents hosted feature service to a map in ArcGIS Map Viewer.
  2. Open the Edit tool.
  3. Create a new incident on the map by adding a new point feature. Pick the appropriate complaint type and location type and leave the remaining information blank in the editing widget.
  4. Note that address attributes, Address, street_name, city, and zipcode, are blank. Incident information attributes, incident_id, agency, and agency_name, are also empty.
  5. Make sure the incident is created successfully.
  6. Leave edit mode by clicking the Edit tool again.
  7. Click on the newly created incident feature to see the information popup. Make sure the Address, street_name, city, zipcode, incident_id, agency, and agency_name information is updated.

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