Contents

REST Run-time Detection and Code Samples

This section is going to cover some code samples related to REST handlers.

Detecting if the Handler is running under REST or HTTP Context

There are time where you may need to create a Service Operation Handler that serves both REST and HTTP services. Most of the code in the handler might be the same between those two. The real difference is generally how you detect parameters. This can be useful when you do not want to duplicate code and you need to serve legacy and new clients. This section will not pertain to all readers in practice.

First let’s take a look at how we can determine at run-time if the service is running under a REST web service setup.

  • You can check the URIResourceIndex property on the Request message object. If it is greater than 0 then you are running under REST.
  • If the value is less than or equal to 0 then you are running under HTTP.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import PS_PT:Integration:IRequestHandler;

class syncTest implements PS_PT:Integration:IRequestHandler
   method onRequest(&msgRequest As Message) Returns Message;
end-class;

method onRequest
   /+ &msgRequest as Message +/
   /+ Returns Message +/
   /+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/

   Local Message &msgReturn = CreateMessage(@("Operation." | &msgRequest.OperationName), %IntBroker_Response);


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


   local boolean &bIsREST = false;

   if &msgRequest.URIResourceIndex > 0 then
     &bIsREST = true;
   end-if;


   &response.SetXmlDoc(&xmlout);
   Return &response;

end-method;

Detecting REST method

There are a few ways to structure your REST Services when you have multiple Methods:

  • GET
  • POST
  • DELETE

You can:

  • Have a different handler for each HTTP Method - (I don’t recommend this)
  • Have a one handler that processes all methods. (Recommended)

When you have a single handler processing different HTTP Methods you are going to need to detect the HTTP Method at run-time and take the appropriate action. Here is a code sample that shows how to detect the HTTP Method.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import PS_PT:Integration:IRequestHandler;

class syncTest implements PS_PT:Integration:IRequestHandler
   method onRequest(&msgRequest As Message) Returns Message;
end-class;

method onRequest
   /+ &msgRequest as Message +/
   /+ Returns Message +/
   /+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/


   Local Message &msgReturn;
   &msgReturn = CreateMessage(@("Operation." | &msgRequest.OperationName), %IntBroker_Response);


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

    Evaluate %This.getRequestMessage().HTTPMethod
      When %IntBroker_HTTP_GET
         /* do some logic */
         Break;
      When %IntBroker_HTTP_POST
         /* do some logic */
         Break;
      When %IntBroker_HTTP_DELETE
         /* do some logic */
         Break;
      When %IntBroker_HTTP_PUT
         /* do some logic */
         Break;
         
      When %IntBroker_HTTP_HEAD
         /* do some logic */
         break;
    End-Evaluate;
 

   &response.SetXmlDoc(&xmlout);
   Return &response;

end-method;

Detecting Content Type

  • TODO

Detecting Accept Type

  • TODO

Author Info
Chris Malek

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

Work with Chris
PeopleSoft REST APIs in Minutes, Not Months
PeopleSoft Simple Web Services (SWS)

SWS turns SQL into production REST APIs — ready for AI, modern apps, and partner integrations. One install, unlimited potential.

  • Configuration-driven, no coding required
  • JSON, XML, and CSV output
  • Works across all PeopleSoft pillars
  • Built on 25+ years of PeopleSoft expertise
Looking for pain-free PeopleSoft web services?
PeopleSoft Simple Web Services (SWS)

A powerful PeopleSoft bolt-on that makes REST web services easy. You bring the SQL, SWS handles the rest.

  • Go from idea to production in minutes
  • Zero code migrations after install
  • JSON, XML, and CSV output supported
  • No PeopleCode or Integration Broker expertise required
Stop Building PeopleSoft Web Services the Hard Way
PeopleSoft Simple Web Services (SWS)

Traditional PeopleSoft web services cost $3,600–$13,000 each to develop. SWS deploys production REST APIs in under 5 minutes through configuration alone.

  • No PeopleCode or Integration Broker expertise required
  • Works across Campus Solutions, HCM, and Financials
  • Built-in pagination, caching, and nested data structures
  • Trusted by institutions across higher education and government
PeopleSoft REST APIs for AI, Modern Apps, and Integrations
PeopleSoft Simple Web Services (SWS)

Turn PeopleSoft data into clean REST APIs for AI integrations, modern applications, and vendor data feeds. Configuration-driven — no PeopleCode required.

  • Deploy production APIs in under 5 minutes
  • AI and LLM ready (RAG, chatbots, intelligent search)
  • JSON, XML, and CSV output
  • Zero modifications to delivered PeopleSoft objects