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.

No comments:

Post a Comment

PeopleCode to retrieve Google map between two addresses

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