Processing REST requests
PolicyCenter calls the methods on the plugin IRestDispatchPlugin interface during the processing of all REST requests. Use the interface methods to control output and logging. As the methods callbacks occur during the processing of a request, Guidewire recommends that these methods not throw exceptions as it is possible for a an exception to hide an operational or serialization error.
Public interface IRestDispatchPlugin contains the following public methods.
- handleReceiveRequest(requestContext)
- PolicyCenter calls the
handleReceiveRequest method upon receipt of each REST request. At
this point in the processing of the request, the REST API framework:
- Has not yet determined the proper operation to take. (The API request can request an unsupported path.)
- Has not authenticated the client that called the request.
- Has not checked permissions for the request.
- handlePreExecute(requestContext, user)
- PolicyCenter calls the handlePreExecute method just prior to setting up the execution environment for the requested operation. If the request requires authentication to perform, this method performs authentication of the user requesting the operation. The handlePreExecute method also determines the correct handler to use to process the request.
- rewriteResponse(requestContext, response)
- If PolicyCenter calls the operation handler on this request and the handler returned successfully, PolicyCenter calls this plugin method just prior to serializing (writing) the response to the request.
- rewriteErrorInfo(requestContext, errorInfo)
- PolicyCenter calls the
rewriteErrorInfo method if processing the client request generates
an error. This error can occur during any of the following phases of the request:
- During set up of the request
- During execution of the requested operation
- During serialization (writing) of the response returned from a successful completion of executed operation
- handleRequestProcessed(requestContext, elapsedMs, handlerResponse, operationError, serializedResponse, serializationError, writeException)
- PolicyCenter explicitly invokes the handleRequestProcessed method after it finishes processing the request and after it closes the response output stream. This is to ensure the time spent in this method does not contribute to the latency of the request call.
