Messaging Methods

This section describes methods used in messaging and the application classes in which they are contained.

Outbound Messaging Methods

This section describes methods used on outbound messages from PeopleSoft to other systems.

Term Definition

OnRequestSend

Implement for outbound synchronous and asynchronous service operations to override connector properties before sending a message to the integration gateway.

This method is contained in the ISend application class.

The OnRequestSend method passes in a message to your derived application class method. The returned value needs to be a message.

The following is an example implementation of this method.

import PS_PT:Integration:ISend;

class SendHandler implements PS_PT:Integration:ISend
   method SendHandler();
   method OnRequestSend(&_MSG As Message) 
    Returns Message;
end-class;

/* constructor */
method SendHandler
end-method;

method OnRequestSend
   /+ &_MSG as Message +/
   /+ Returns Message +/
   /+ Extends/implements PS_PT:Integration:ISend. +/
   /+ OnRequest Send +/
   /* Variable Declaration */
   Local any &tempNode;
   Local any &rootNode;
   Local any &xmlDoc;
   Local any &msg;
   &msg = &_MSG;
   &xmlDoc = &msg.GetXmlDoc();
   /* Add a node to the doc to prove that we can 
      edit it in this event. */
   &rootNode = &xmlDoc.DocumentElement;
   &tempNode = &rootNode.AddElement("OnSend");
   &tempNode.NodeValue = "If you see this, then 
   the Sync OnSend PCode has altered the message";
   /* and write the data back into the message */
   &msg.SetXmlDoc(&xmlDoc);
   Return (&msg);
end-method;

See Setting and Overriding Target Connector Properties at Runtime.

When using the ISend handler with message parts, specifically with rowset-based message parts, the rowsets of the parts must be retrieved in the order that the content data will be sent.

The following is an example that can be used for ISend events that use rowset-based parts (even for the cases where one is just overriding the connectors):

method OnRequestSend
   /+ &MSG as Message +/
   /+ Returns Message +/
   /+ Extends/implements PS_PT:Integration:ISend. +/
   /+ OnRequestSend +/
   If (&MSG.IsPartsStructured) Then
      Local number &i;
      Local Rowset &rs;
      For &i = 1 To &MSG.PartCount
         &rs = &MSG.GetPartRowset(&i);
      End-For;
   End-If;

      Return &MSG;
end-method;

OnAckReceive

Implement for outbound asynchronous service operations to access the body of a message acknowledgement to check for SOAP faults.

This method is contained in the IReceiver application class.

The following is an example implementation of this method.

import PS_PT:Integration:IReceiver;

class AckReceiveHandler implements PS_PT:
  Integration:⇒
IReceiver
   method AckReceiveHandler();
   method OnAckReceive(&_MSG As Message) Returns 
   integer;
end-class;

/* constructor */
method AckReceiveHandler
end-method;

method OnAckReceive
   /+ &_MSG as Message +/
   /+ Returns Integer +/
   /+ Extends/implements PS_PT:Integration:+/
   /+ IReceiver.OnAck Receive +/
   /* Variable Declaration */
   /*  
/* We return a hardcoded value. In this case, a 
   message error.*/
   Return (%Operation_Error);
end-method;

See Handling Inbound Asynchronous Transactions.

Inbound Messaging Methods

This section describes methods used on inbound messages to PeopleSoft from other systems.

Term Definition

OnRequest

Implement for inbound synchronous service operations.

This method is contained in the IRequestHandler application class.

The following is an example implementation of this method:

class RequestHandler implements PS_PT:Integration:
 IRequestHandler
   method RequestHandler();
   method OnRequest(&_MSG As Message) Returns 
   Message;
end-class;

/* constructor */
method RequestHandler
end-method;

method OnRequest
   /+ &_MSG as Message +/
   /+ Returns Message +/
   /+ Extends/implements PS_PT:Integration:+/
   /+ IRequestHandler.OnRequest +/
   /* Variable Declaration */
   Local any &tempNode;
   Local any &descNode;
   Local any &rootNode;
   Local any &xmlDoc;
   Local any &xmldata;
   Local any &msg;
   &msg = CreateMessage(Operation.QE_IB_SYNC_RESP,%Int⇒
Broker_response);
   &xmldata = "<?xml version='1.0'?>
   <QE_IB_PeopleCode_Test⇒/>";
   &xmlDoc = CreateXmlDoc(&xmldata);
   &rootNode = &xmlDoc.documentelement;
   &descNode = &rootNode.AddElement("Description");
   &descNode.NodeValue = "Sync test of OnRouteSend.";
   &tempNode = &rootNode.addelement("OnRequest");
   &tempNode.NodeValue = "If you see this,
   then the On Request PCode created the response 
   message";
   &msg.SetXmlDoc(&xmlDoc);
   Return &msg;

OnNotify

Implement for inbound asynchronous service operations. This method can be used for code that does subscription processing, and for validating and loading message data.

This method is contained in the INotificationHandler application class.

The following is an example implementation of this method:

import PS_PT:Integration:INotificationHandler;

class NotificationHandler implements PS_PT:Integration:
  INotificationHandler
   method NotificationHandler();
   method OnNotify(&_MSG As Message);
end-class;

/* constructor */
method NotificationHandler
end-method;

method OnNotify
   /+ &_MSG as Message +/
   /+ Extends/implements PS_PT:Integration: +/
   /+ INotificationHandler.OnNotify +/
   /* Variable Declaration */
   Local Rowset &rs;
   &rs = &MSG.GetRowset();
   /* process data from rowset */
end-method;

OnResponse

Implement for inbound response asynchronous service operations.

This method can be used for code that does response subscription processing. This method is contained in the INotificationHandler application class.

The following is an example implementation of this method and shows how to get the request TransactionID.

import PS_PT:Integration:INotificationHandler;

class RESPONSE_NOTIFICATION implements PS_PT:
 Integration:INotificationHandler
   method RESPONSE_NOTIFICATION();
   method OnNotify(&MSG As Message);
end-class;

/* constructor */
method RESPONSE_NOTIFICATION
   %Super = create PS_PT:Integration:INotificationHandler⇒
();
end-method;

method OnNotify
   /+ &MSG as Message +/
   /+ Extends/implements PS_PT:Integration:+/
   /+ INotification Handler.OnNotify +/
   Local Rowset &rs;
   Local boolean &Ret;
   Local string &TransactionID;
   &rs = &MSG.GetRowset();
   If &MSG.IsSourceNodeExternal Then
      /* if the request came from an external non 
        PeopleSoft System then you can get the 
        original TransactionID from the WSA_MessageID
        from the request message. */
      &TransactionID = &MSG.IBInfo.WSA_MessageID;
   Else
      /* if the request came from a PeopleSoft 
         System then get the original TransactionID 
         from the  nReplyToID */
      &TransactionID = &MSG.IBInfo.InReplyToID;
   End-If;
end-method;

Error-Handling Methods

Each application class contained in the Integration application subpackage contains an OnError method that you can use for custom error handling.

Custom error handling can include sending an email notification or entering data in a log when an error occurs.

For the IRequestHandler application class, the OnError function returns a string. This enables you to send back custom error messages, for example SOAP faults, to non-PeopleSoft consumers. If the message consumed was a SOAP message and the custom error message is already wrapped in SOAP, it will not be modified and is sent as-is. However, if the OnError message is not SOAP, it is wrapped as a standard SOAP fault and returned to the sender.

If the message consumer is another PeopleSoft system the message set/message ID framework applies.

If an error occurs the OnError method, if implemented, is automatically invoked. The type of exception can be viewed by using the Message object to retrieve an Exception object populated with information about the error, using the message class IBException property.

The following is an example of the OnError method implementation:

/*On Error Implementation */
method OnError
   /+ &MSG as Message +/
   /+ Returns String +/
   /+ Extends/implements PS_PT:Integration:IRequestHandler.OnError +/
   Local integer &nMsgNumber, &nMsgSetNumber;
   Local string &sText;
   &nMsgNumber = &MSG.IBException.MessageNumber;
   &nMsgSetNumber = &MSG.IBException.MessageSetNumber;
   rem    &sText = &exception.DefaultText;
   &sText = &MSG.IBException.ToString();
   /* ADD SPECIFIC ERROR INFO HERE */
   Return &sText;
end-method;

See PeopleCode API Reference: Understanding Exception Class.

See PeopleCode API Reference: IBException property: Message class.