HTTP Post to PeopleSoft Integration Broker Asynchronous

 

In this post, I will lay out a simple example that will show how to use an HTTP client to post to the PeopleSoft Integration Broker HttpListeningConnector. PeopleSoft will process the message Asynchronously. This will be a trivial example that will hopefully help someone jump start an integration project.

In the example laid out below:

  • We are posting to an asynchronous Service operation in PeopleSoft
  • We are not actually doing anything with the data in PeopleSoft other than echo it to an email in-box

Create a New PeopleSoft Message Object

Now we need a PeopleSoft message object that will represent the XML that the client program will post.

Message AttributeValue
NameCHG_GENERIC
VersionV1
TypeNonrowset-based

Messages

Create a new Service

In this example, we create a new service.

Service AttributeValue
NameCHG_TEST

Create the Handler PeopleCode

Now we need to create some PeopleCode that will run when a new message is posted to the integration broker for this Service Operation.

  • Create an Application Package and Class with the following : CHG_ASYNC_TEST:asyncTest
  • Paste in the following code into the Class:
import PS_PT:Integration:INotificationHandler;


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

method OnNotify
   /+ &_MSG as Message +/
   /+ Extends/implements PS_PT:Integration:INotificationHandler.OnNotify +/
   /* Variable Declaration */
   
   
   Local XmlDoc &doc;
   &doc = &_MSG.GetXmlDoc();
   
   Local XmlNode &xrootNode;;
   
   &xrootNode = &doc.DocumentElement;
   
   Local integer &ucount;
   SQLExec("SELECT COUNT(*) FROM PSOPRDEFN WHERE ACCTLOCK = 0 ", &ucount);
   

end-method;

This is a really dumb example that does nothing useful. However, what we can see is we can:

  • Get access to the XML submitted by the client using the &_MSG.GetXmlDoc(); method.
  • Run arbitrary PeopleCode like SQLExecs or whatever.
  • Notice that the OnNotify does NOT return anything.

Setup new Service Operation

Now we need to setup the actual Service Operation. There are several steps here.

Service Operation AttributeValue
NameCHG_ASYNC_TEST
TypeAsynchronous - One Way
VersionV1
ActiveChecked
Message VersionCHG_GENERIC.V1
Queue NameIB_EXAMPLES (or create a new queue )
  • Click on the “Service Operation Security” link and add the permission we created in the pre-req section.

Service Operation Defn.

Now we need to hook in the CHG_ASYNC_TEST:asyncTest application class to execute when a service operation is posted. We do this on the Handler tab of the Service Operation.

Service Operation Handler AttributeValue
Handler NameTest
Handler TypeOn Notify
ImplementationApplication Class
DescriptionTester
Package NameCHG_ASYNC_TEST
Path:
Class IDasyncTest
MethodOnNotify

SO Handler

Now we need to setup the routing to make this node able to send Service Operations.

Service Operation Routing AttributeValue
routing nameCHG_ASYNC_TEST
sender nodeCHG_TEST_NODE
Receiver NodePSFT_CS (whatever your default local node is )
External AliasCHG_ASYNC_TEST.V1
ActiveChecked

SO Handler

Now our PeopleTools system should be ready to receive messages from some HTTP client.

Submitting data

Now we can use an HTTP Client to invoke the Service operation. Remember that this is an asynchronous service. This means that the actualy onNotify handler is actually handled at some point in the future. What we get back is a TransactionID in both the response payload and an response HTTP header. This is the ID that can be used to lookup the message determine what the handler did and if it ran.

Synchronous HTTP Post to PeopleSoft Integration Broker (Its not a REST base service)

 Introduction

This section will show a simple example of using the HttpListeningHandler to post to PeopleSoft using a synchronous service operation. This is the request/reply paradigm where code is run in response to in inbound message.

In this article:

  • We are posting to an Synchronous Service operation in PeopleSoft
  • The PeopleCode that is executed will examine the XML sent and do something different depending on the content. The response will also be different based on the input.

Detail view:-

  • Create a New PeopleSoft Message Object: Navigation: PeopleTools > Integration Broker > Integration Setup > Messages
  • Create a new Service: Navigation: PeopleTools > Integration Broker > Integration Setup > Service
  • Create the Handler PeopleCode
  • Setup new Synchronous Service Operation - Version, Routing and Service Operation Security
  • Assign Service Handler Class into Service Operation
  • Test

Create a New PeopleSoft Message Object

Now we need a PeopleSoft message object that will represent the XML that the client program will post.

Message AttributeValue
NameCHG_GENERIC
VersionV1
TypeNonrowset-based
Message

Create a new Service

In this example, we create a new service. You can easily re-use another service if you wish.

Service AttributeValue
NameCHG_TEST_SYNC
Service

Create the Handler PeopleCode

Now we need to create some PeopleCode that will run when a new message is posted to the integration broker for this Service Operation.

  • Create an Application Package and Class with the following Package Class Name: CHG_SYNC_TEST:syncTest
  • Paste in the following code into the Class:
import PS_PT:Integration:IRequestHandler;

class syncTest 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 &xmlDocFromPython;

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

   &requestRootNode = &xmlDocFromPython.DocumentElement;


   /* Setup response xml body */

   Local Message &response;
   &response = CreateMessage(Operation.CHG_SYNC_TEST, %IntBroker_Response);
   Local XmlDoc &xmlout;

   Local XmlNode &childNode;
   &xmlout = CreateXmlDoc("<?xml version='1.0'?><response/>");


   Evaluate Lower(&requestRootNode.NodeName)
   When = "helloworld"
      &childNode = &xmlout.DocumentElement.AddElement("helloworld").AddText("Hello client");
      Break;

   When = "activeusercount"

      Local integer &ucount;
      SQLExec("SELECT COUNT(*) FROM PSOPRDEFN WHERE ACCTLOCK = 0 ", &ucount);

      &childNode = &xmlout.DocumentElement.AddElement("activeusercount").AddText(String(&ucount));
      Break;

   When-Other
      &childNode = &xmlout.DocumentElement.AddElement("error").AddText("I do not understand. Please try again. You submitted: " | &requestRootNode.NodeName);
      Break;
   End-Evaluate;


   &response.SetXmlDoc(&xmlout);

   Return &response;

end-method;
  • A synchronous request must implement the OnRequest method.
  • You will see that the code examines the Root Node of the XML and will run a different branch of code depending on the input.
    • “helloworld” - If the root node is “helloworld” we will just echo back a “Hello client” message.
    • “activeusercount” - If the root node is “activeusercount”, then we will do a count of all unlocked users in the system and return that in a response
    • If any other root node is passed in we return an error message that the input was not understood and we echo back the root node name in the message.

This will probably make a little more sense later in the article when we look at the request and response from the Python client.

Setup new Synchronous Service Operation

Now we need to setup the actual Service Operation. There are several steps here.

Service Operation AttributeValue
NameCHG_SYNC_TEST
TypeSynchronous
VersionV1
ActiveChecked
Message VersionCHG_TEST.V1
Queue NameIB_EXAMPLES (or create a new queue )
  • Click on the “Service Operation Security” link
    • Input a permission list that you have on your user profile.
    • Additionally, assign permission lists grants to a permission list that is on your “default user id” from your node definition.

Now we need to hook the CHG_I_TESTER:syncTester application class to execute when a service operation is posted. We do this on the Handler tab of the Service Operation.

Service Operation Handler AttributeValue
Handler NameTest (This value will be over written by peoplecode)
Handler TypeOnRequest
ImplementationApplication Class
DescriptionTester
Package NameCHG_I_TESTER
Path:
Class IDsyncTest
MethodOnRequest

Now we need to setup the routing to make this node able to send Service Operations.

Service Operation Routing AttributeValue
routing nameCHG_IN_SYNC_TEST
sender nodeCHG_TEST_NODE
Receiver NodePSFT_CS (or whatever your default local node is )
External AliasCHG_SYNC_TEST.V1
ActiveChecked
SO Add SO Page 1 SO Handler SO routing

IB Object diferences between PeopleTools 8.47 and earlier releases and PeopleTools 8.48 and higher releases

 

Integration Metadata

PeopleTools 8.4x Objects

( PeopleTools 8.47 and Earlier)

PeopleTools 8.48 and Higher Objects

Node.

Node.

Channel.

Queue.

Message.

Message.

Node transactions and relationships.

Service, Service Operations, Service Operation Versions, and Routings.

Message and Subscription PeopleCode.

Application classes and service operation handlers.

Integration PeopleCode

PeopleTools 8.4x PeopleCode

(PeopleTools 8.47 and Earlier)

PeopleTools 8.48 and Higher PeopleCode

Message and subscription PeopleCode.

Application classes.

PeopleCode events.

Service operation handlers.


PeopleCode Methods

PeopleTools 8.4x Integration PeopleCode Events

(PeopleTools 8.47 and Earlier)

PeopleTools 8.48 Integration PeopleCode Base Classes and Methods

(PeopleTools 8.48 and Higher)

OnRequest

IRequestHandler:OnRequest

OnAckReceive

IReceiver:OnAckReceive

OnRouteReceive

IRouter: OnRouteReceive

OnRouteSend

IRouter:OnRouteSend

OnSend

ISend:OnRequestSend

Subscription

INotification:OnNotify


PeopleCode to retrieve Google map between two addresses

  PeopleCode Example: /* Define constants for the API request */ Local string &origin = "123 Main St, Anytown, USA";   /* ...