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:
- Audit log - performs the task of audit logging
- Geocoding - fetches the address information based on user input location
- 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.
- Download the sample dataset from here.
- In Portal for ArcGIS, go to Content > My Content and click the New item button.
- Drag or upload
incidents.gdb
(zipped) to the New item window. - 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.
- Ensure the Title for the hosted feature service is “incidents” and click the Save button.
- 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.
- Make sure to enable the editing capabilities for hosted feature service.
Alternatively, you can also create the editing-enabled hosted feature service using ArcGIS Pro.
Download the sample code
- The pre-built audit log interceptor sample is available here: Audit log interceptor
- The pre-built geocoding interceptor sample is available here: Geocoding interceptor
- The pre-built system integration interceptor sample is available here: System integration interceptor
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.
- Unzip the sample into a location of your choosing.
- In a web browser, navigate to the ArcGIS Server Administrator Directory and sign in as an administrator.
- Click uploads > upload.
- On the Upload Item page, click the Choose File button and select the
<sample name
file located in the>.interceptor <sample name
folder in the directory where you unzipped the sample in Step 1 above.>/target - Click the Upload button. Once the file is uploaded, you will be directed to the Uploaded Item page. Copy the Item ID.
- Browse to Home > system.
- 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 - 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.
- Navigate to
<domain
.>/ <server-web-adaptor >/admin/system/interceptors/chainingorder - In the Chaining Order input box, update the chaining order to match what is shown below:
[
{
"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.
- 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.
- Navigate to
<domain
.>/ <server-web-adaptor >/rest/services/ Hosted - Perform a query operation on the incidents hosted feature layer.
- 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."
To inspect the behavior of the geocoding and system integration interceptors, follow steps below.
- Add the incidents hosted feature service to a map in ArcGIS Map Viewer.
- Open the Edit tool.
- Create a new incident on the map by adding a new point feature. Pick the appropriate
complaint type
andlocation type
and leave the remaining information blank in the editing widget. - Note that address attributes,
Address
,street
,_name city
, andzipcode
, are blank. Incident information attributes,incident
,_id agency
, andagency
, are also empty._name - Make sure the incident is created successfully.
- Leave edit mode by clicking the Edit tool again.
- Click on the newly created incident feature to see the information popup. Make sure the
Address
,street
,_name city
,zipcode
,incident
,_id agency
, andagency
information is updated._name