Author Info
Chris Malek

Chris Malek is a PeopleTools® Technical Consultant with two decades of experience working on PeopleSoft enterprise software projects. He is available for consulting engagements.

About Chris Work with Chris
Looking for pain-free PeopleSoft web services? 😀
PeopleSoft Simple Web Services (SWS)

Introducing a small but powerful PeopleSoft bolt-on that makes web services very easy. If you have a SQL statement, you can turn that into a web service in PeopleSoft in a few minutes.

Contents

OnRequest Handler

  • Description - This handler is used to process a synchronous request. This the type of handler you will most often implement for a web service to a third party. It takes the request, parses it, does something and returns a response.

  • Inputs - Message Object sent by the client.

  • Outputs - Message object to be returned to the client as the response.

  • Application Class Interface

    • PS_PT:Integration:IRequestHandler

Template OnRequestCode

Below is a template code that can get you started with an OnRequest handler. The onRequestTemplateHandler class name needs to be changed. This example pulls in the inbound XML document but does not actually do anything with it. It also returns a hard coded response.

import PS_PT:Integration:IRequestHandler;

class onRequestTemplateHandler implements PS_PT:Integration:IRequestHandler
   method onRequest(&MSG As Message) Returns Message;
end-class;

method onRequest
   /+ &MSG as Message +/
   /+ Returns Message +/
   /+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/


   Local XmlDoc &xmlDocInBound;

   Local XmlNode &requestRootNode;
   &xmlDocInBound = &MSG.GetXmlDoc();

   &requestRootNode = &xmlDocInBound.DocumentElement;


   /* Setup response xml body */

   Local Message &response;
   &response = CreateMessage(&msg.OperationName, %IntBroker_Response);
   Local XmlDoc &xmlout;
   &xmlout = CreateXmlDoc("<?xml version='1.0'?><response/>");

   Local XmlNode &childNode;

   &childNode = &xmlout.DocumentElement.AddElement("helloworld").AddText("greetings");
   
   &response.SetXmlDoc(&xmlout);

   Return &response;

end-method;

Parking Lot

/* This interface is the equivalent of the OnRequest PeopleCode event 
in 8.4x tools. OnRequest will pass in a message to your derived 
application class method. The return needs to be a message. 

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 its 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 wrappered 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.

(REST based Service Only)
The Response Code will be automatically set based
on the value defined for the Fault Message on the Service Operation Defintion.
*/

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