By | 05 April 2013

Synchronous HTTP Post to PeopleSoft Integration Broker using Python

This is a follow-up post for HTTP Post to PeopleSoft Integration Broker using Python. In that article, we showed how to post to an asynchronous service operation. In the PeopleTools architecture, when you post asynchronously, the PeopleSoft code that triggers is NOT ran instantaneously. It will run at some point in the future or could be canceled by an administrator and never run.

If your integration scenario is one that you need to ensure that PeopleSoft processes the message and your client software needs the response immediately, then you need to create a synchronous service operation. This type of service operation is slightly different on the PeopleSoft setup and the PeopleCode that gets triggered is also slightly different. The Python client code is almost identical in regards to actually making the HTTP calls and the message structure. The Python code in this article will get more functionality than we had in the asynchronous example.

In this article:

  • We are using Python 3.3 standard libraries.
  • 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 Python input.
  • We are not doing too much error handling in the python script.

The PeopleTools Setup

First let’s setup the PeopleSoft side.

Step 1 – Setup a Node to represent your python program

First we need a node to represent your application. This can be done here: PeopleTools > Integration Broker > Integration Setup > Nodes

Node Attribute Value
Node Type External
Authentication Option Password
Default User ID PS (or some valid user in your system. )
Password ^secret^ (Note this is NOT the password for any user. This is more like a “key” for the node)
Active Checked

Step 2 – Create a New PeopleSoft Message Object

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

PeopleTools > Integration Broker > Integration Setup > Messages

Message Attribute Value
Version V1
Type Nonrowset-based

Step 3 – Create a new Service

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

PeopleTools > Integration Broker > Integration Setup > Services

Service Attribute Value

Step 4 – 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 Naming: CHG_I_TESTER:syncTester
  • Paste in the following code into the Class:
import PS_PT:Integration:IRequestHandler;

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

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 Python");

   When = "activeusercount"

      Local integer &ucount;

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

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


   Return &response;

  • This code is different than our asynchronous example. We have to implement a different class and 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 Python” 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.

Step 5 – Setup new Synchronous Service Operation

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

PeopleTools > Integration Broker > Integration Setup > Service Operation

Service Operation Attribute Value
Type Synchronous
Version V1
Active Checked
Message Version CHG_TEST.V1
Queue Name IB_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 Attribute Value
Handler Name Test (This value will be ovewritten by peoplecode)
Handler Type OnRequest
Implementation Application Class
Description Tester
Package Name CHG_I_TESTER
Path :
Class ID syncTester
Method OnRequest

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

Service Operation Routing Attribute Value
routing name IN_P_TEST
sender node PTEST
Receiver Node HRMS (whatever your default local node is )
External Alias CHG_SYNC_TEST.V1
Active Checked

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

Python Script

  • Download the python code
  • Replace the following pieces of code for your environment
    • Change the assignment to url with your PeopleTools host.
    • Change any headers['xxx'] assignments to reflect the nodes and other attributes for your installation.

Running the Script

The Python script is written to handle a command line flag. The flag/command passed in will get submitted to the Integration Broker in an XML root node. The PeopleCode will look for two different root nodes and do two different things based on those commands passed in. If some other command is passed in, then the PeopleCode will just return a generic response telling you there was an error. Let’s look at it in detail.

Let’s first try the “helloworld” command.

python3 helloworld

The python script will submit the following XML to the Integration Broker.

<?xml version="1.0" ?>

This will cause the “helloworld” branch of the PeopleCode to run and PeopleSoft will return this XML.

    <helloworld>Hello Python</helloworld>

If you call the Python script with the “activeusercount” command like this:

python3 activeusercount

It will submit the following XML to the Integration Broker:

<?xml version="1.0" ?>

That will cause the PeopleCode to do an active user profile count and return some XML formatted like this:


If you call the Python script with some junk that the PeopleCode cannot understand like this:

python3 blah

The XML submitted to the Integration broker will look like this:

<?xml version="1.0" ?>

The PeopleSoft XML response will look like this:

     <error>I do not understand. Please try again. You submitted: blah</error>


So what did we learn? We learned that you can pretty much submit any XML to a synchronous Service Operation and have it respone to what was submitted. Of course, the functionality presented here is completely useless. You can extrapolate the example here to do whatever. The Python client could be sending in actual data in the XML. The PeopleCode could actually parse the data and update something in PeopleSoft and return a response. It is up to the two systems to agree upon an XML format to exchange.

Additional Reading

Do you want to become a CI Expert?

If you want to learn more about developing using Component Interface then check out our CI Training Video.