Skip to content

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. Geocoding - fetches the address information based on user input location.
  2. System Integration - updates the attributes of existing features by integrating with an external system.
  3. Response Enrichment - intercepts the response for adding static values to specific fields when perform a query or edit operation.

Supported ArcGIS Enterprise SDK Versions

  • 12.0 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.
  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. Set the file type as File geodatabase
  5. Ensure the Title for the hosted feature service is incidents and click the Save.
  6. Navigate to Content > My Content and click on the incidents hosted feature layer to open the item page. Go to the Settings and click Feature layer (hosted).
  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 interceptors is done in two parts: upload and register.

Upload and Register

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

  1. Unzip the sample into a location of your choosing.
  2. Navigate to ArcGIS Server Administrator Directory and sign in as an administrator.
  3. Click uploads > upload.
  4. On the Upload Item page, click the Choose File 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. Once the file is uploaded, you will be directed to the Uploaded Item page. Copy the Item ID.
  6. Navigate to Home > system > interceptors. The corresponding URL is: <domain>/<server-web-adaptor>/admin/system/interceptors.
  7. Click register and paste the value of the Item ID obtained in Step 5 into the input field.
  8. Click the Register to complete the register.

Manage the Chaining Order

This sample applies business rules using three interceptors. The first interceptor automatically derives and inserts address information for new incidents feature based on the map location selected by the user. The second interceptor synchronizes business-critical fields, including incident ID, agency name, and other attributes, from external systems. The third interceptor enriches the service response with static values whenever query or edit operations are performed.

  1. Navigate to <domain>/<server-web-adaptor>/admin/system/interceptors/chainingorder.
  2. In the Chaining Order input box, chaining order should 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": "Geocoding",
            "chainingOrder": 1,
            "urlPatterns": ["Hosted/incidents/FeatureServer"]
        },
        {
            "interceptorName": "SystemIntegration",
            "chainingOrder": 2,
            "urlPatterns": ["Hosted/incidents/FeatureServer"]
        },
        {
            "interceptorName": "ResponseEnrichment.interceptor",
            "chainingOrder": 3,
            "urlPatterns": ["Hosted/incidents/FeatureServer"]
        }
    ]

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 Chaining sample, follow steps below.

  1. In Map Viewer, add the incidents hosted feature service to a new map.
  2. Before enabling the Chaining interceptors, ensure that the attributes agency, agency_name,resolution_description and last_action_date are empty for existing features. You can verify this in Map Viewer. Checking point before enable interceptor
  3. Open the Edit tool.
  4. Create a new incident by clicking the Add in the Edit pane. Choose the appropriate complaint type and location type and leave the remaining information blank in the editing widget.
  5. Click the newly created point to view the incident feature. You will observe that all fields, other than complaint_type and location_type, are empty. Create a new point before enable interceptor
  6. Register the three interceptors with the steps listed in the above section Deploy the Interceptors.
  7. In the Map Viewer, refresh the map to ensure the latest version of the incidents hosted feature service is loaded.
  8. Create a new incident on the map by adding a new point feature. Choose the appropriate complaint type and location type and leave the remaining information blank in the editing widget.
  9. Leave edit mode by clicking the Edit tool again.
  10. Click on the newly created incident feature to see the information popup. Make sure the address, street_name, city, zipcode, incident_id, agency, agency_name,resolution_description and last_action_date information is added. Create a new point after enable interceptor
  11. Click on other existing incident features to see if the incident_id, agency, agency_name,resolution_description and last_action_date information is inserted to those features as well. Checking point after enable interceptor

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