Defining Properties for Provider REST Service Operation Application Class

For Integration Broker, there are two properties that can be defined for a REST provider Service Operation Application Class. These two properties, when implemented, can override the Content Type and Response Code for the OnError event.

The application package: PS_PT application package,

method IRequestHandler defined in its comments refers to these properties and how to use them.

If an error occurs the OnError method, if implemented, will be automatically invoked. The type of exception can be viewed by using the Message object to retrieve the Exception object (&Message.IBException).

Please see the PeopleCode Language Reference guide for more information about the Exception class.

OnError

The return string of this method is used for a custom error message back to the sender (if it’s not PeopleSoft). If the request was via SOAP then the string will be wrapped in a SOAP FAULT and returned. If the string itself is SOAP then it will not be wrapped but sent back as is.

Note that the return string is optional, in that if the string is null then the Integration Broker runtime will handle the error.

OnError Functionality (REST Based Service Only)

The Response Code and Content Type will be automatically set based on the value defined for the Fault Message on the Service Operation Definition. These can be overridden by setting the property OnErrorHttpResponseCode and/or the property OnErrorContentType.

*/

interface IRequestHandler
   method OnRequest(&message As Message) Returns Message;
   method OnError(&request As Message) Returns string;
   property integer OnErrorHttpResponseCode;
   property string OnErrorContentType;
end-interface;

The following example illustrates how to invoke these properties using the OnError method:

import PS_PT:Integration:IRequestHandler;

class WeatherData implements PS_PT:Integration:IRequestHandler
   method WeatherData();
   method OnRequest(&MSG As Message) Returns Message;
   method OnError(&request As Message) Returns string;
   property integer OnErrorHttpResponseCode;
   property string OnErrorContentType;

/* constructor */
method WeatherData
end-method;

method OnRequest
   /+ &MSG as Message +/
   /+ Returns Message +/
   /+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/
   /* Variable Declaration */
   ....
   Return &response;
end-method;

method OnError
   /+ &request as Message +/
   /+ Returns String +/
   /+ Extends/implements PS_PT:Integration:IRequestHandler.OnError +/
   Local Message &Fault_Msg;
      /* Create the fault string exception based on the proper format to be sent back  */
      /* Override the content type and Response Code in this case
      %This.OnErrorHttpResponseCode = 405;
      %This.OnErrorContentType = "application/json";
      Return <The fault string>;
   End-If;
end-method;