Author Info
Chris Malek

Chris Malek is a PeopleTools® Technical Consultant with two decades of experience working on PeopleSoft enterprise software projects. He is available for consulting engagements.

About Chris Work with Chris
Do you need a quick way to create web services?
PeopleSoft Simple Web Services (SWS)

Introducing a small but powerful PeopleSoft bolt-on that makes web services very easy. If you have a SQL statement, you can turn that into a web service in PeopleSoft in a few minutes.

Read More & Purchase

Useful Code Snippets

Below are a collection of useful code snippets.

Get Query String Parameters

This code will allow you to extract out query string parameters from the HttpListeningConnector. The client can add any key value pairs to URL and your handler code can pick them up.

Imaging that a client using your web service is posting to your web service and wants to add some more parameters that are not really part of the payload. I often use this strategy to allow for setting log level or maybe some testing flags. Here we add a LogLevel and RollBack parameters.


If you want to extract those in your handler you can use the following code in your application class.

First define the method.

method getQueryStringParameter(&inboundMessage As Message, &parmName As string) Returns string;

The method implementation is:

method getQueryStringParameter
   /+ &inboundMessage as Message, +/
   /+ &parmName as String +/
   /+ Returns String +/
   Local string &argname;
   Local integer &i;
   /* where &msg = inbound message */
   For &i = 1 To &inboundMessage.IBInfo.IBConnectorInfo.GetNumberOfQueryStringArgs()
      &argname = &inboundMessage.IBInfo.IBConnectorInfo.GetQueryStringArgName(&i);
      If Upper(&argname) = Upper(&parmName) Then
         Return &inboundMessage.IBInfo.IBConnectorInfo.GetQueryStringArgValue(&i);
   Return "";

Then if you want to extract the LogLevel parameter, you can call the method like:

&logLevelValue = %this.getQueryStringParameter(&msg, "LogLevel")

Get content-type Header

If you need to get the content-type header that the client sent which should represent the message encoding you can use the following code.

&MSG is the inbound message object passed to the handler. You may have a different variable name for that.

local string &contentType;

&contentType = &MSG.SegmentContentType;

Set HTTP Header

To set an HTTP Header in the response it would look something like this:

  Local boolean &bTmp;

   &bTmp = &msgResponse.IBInfo.IBConnectorInfo.AddConnectorProperties("x-current-user, %operatorid, %Header);

Get an HTTP Header

To find an HTTP Header you have to loop over all the GetConnectorPropertiesType properties of the request message object. In the code sample below, we are looking for a header named x-custom-header and populating a variable called &headerValue with it’s value if it exists.

/* &msgRequest is the inbound request message */ 

Local integer &i;
local string &headerName;
local string &headerValue;

&headerName = "x-custom-header";

For &i = 1 To &msgRequest.IBInfo.IBConnectorInfo.GetNumberOfConnectorProperties();
   If &msgRequest.IBInfo.IBConnectorInfo.GetConnectorPropertiesType(&i) = "HEADER" And
         Upper(&msgRequest.IBInfo.IBConnectorInfo.GetConnectorPropertiesName(&i)) = Upper(&headerName) Then
      &headerValue =  &msg.IBInfo.IBConnectorInfo.GetConnectorPropertiesValue(&i);

If you need to get a HTTP cookie submitted with your request you can add this method to your handler code.

   method getCookieFromRequest
      /+ &MSG as Message, +/
      /+ &cookieName as String +/
      /+ Returns String +/

      Local string &requestCookies;


         &requestCookies = &MSG.IBInfo.IBConnectorInfo.Cookies;

         Local array of string &aInboundCookiesKeyValues;
         &aInboundCookiesKeyValues = CreateArrayRept("", 0);
         &aInboundCookiesKeyValues = Split(&requestCookies, ";");

         Local integer &i;

         Local array of string &aKeyValue;

         Local integer &cookieValLocationStart;
         For &i = 1 To &aInboundCookiesKeyValues.Len
            &aKeyValue = Split(&aInboundCookiesKeyValues [&i], "=");

            If LTrim(RTrim(&aKeyValue [1])) = &cookieName Then
               Return &aKeyValue [2];

         Return "";

      catch Exception &E
         Return "";;

The usage would look something like this:

Local string &cValue;

&cValue = %This.getCookieFromRequest(&MSG, "PS_TOKEN");

There does not seem to be a way to set a cookie.

There is some code example in PeopleBooks but this does not work in REST.

&msgReturn.IBInfo.IBConnectorInfo.Cookies = "goodcookie=PEANUTBUTTER;";