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 Attribute | Value |
---|---|
Name | CHG_GENERIC |
Version | V1 |
Type | Nonrowset-based |
Create a new Service
In this example, we create a new service.
Service Attribute | Value |
---|---|
Name | CHG_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 Attribute | Value |
---|---|
Name | CHG_ASYNC_TEST |
Type | Asynchronous - One Way |
Version | V1 |
Active | Checked |
Message Version | CHG_GENERIC.V1 |
Queue Name | IB_EXAMPLES (or create a new queue ) |
- Click on the “Service Operation Security” link and add the permission we created in the pre-req section.
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 Attribute | Value |
---|---|
Handler Name | Test |
Handler Type | On Notify |
Implementation | Application Class |
Description | Tester |
Package Name | CHG_ASYNC_TEST |
Path | : |
Class ID | asyncTest |
Method | OnNotify |
Now we need to setup the routing to make this node able to send Service Operations.
Service Operation Routing Attribute | Value |
---|---|
routing name | CHG_ASYNC_TEST |
sender node | CHG_TEST_NODE |
Receiver Node | PSFT_CS (whatever your default local node is ) |
External Alias | CHG_ASYNC_TEST.V1 |
Active | Checked |
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.