Contents
Contents

XML Encoding Examples

Struggling to bridge the legacy gap? Cedar Hills Group provides specialized PeopleSoft integration consulting to help teams design, build, and optimize their connection strategies.

In this section, we will look at how to create XML with PeopleCode. We do not use the message class to generate any XML. The PeopleCode is used to entirely generate the content.

Simple XML Output

This example shows how to produce a simple XML output in an handler. Below is the XML produced with the handler PeopleCode that is below. This is meant to demonstrate a few key concepts.

  • Producing an nested XML structure
  • Adding XML attributes to node
  • Show the different with character escaping differences between CDATA and Nodes
<?xml version="1.0"?>
<RESPONSE>
  <hello DEBUG_NODE="True">world</hello>
  <STRING_TEST_CDATA>
    <![CDATA[<p><b>I have characters that should be escaped</b></p>]]>
  </STRING_TEST_CDATA>
  <STRING_TEST>&lt;p&gt;&lt;b&gt;I have characters that should be escaped&lt;/b&gt;&lt;/p&gt;</STRING_TEST>
  <META isMETA="True">
    <OPRID>PS</OPRID>
    <CURRENT_TIME>2019-10-21-19.20.31.000000</CURRENT_TIME>
    <TRANSACTION_ID>d95ffa9d-f437-11e9-8a51-fef2b534ad6a</TRANSACTION_ID>
    <DBNAME>CS92U009</DBNAME>
  </META>
</RESPONSE>

The full handler PeopleCode to produce this XML is the following.

import PS_PT:Integration:IRequestHandler;

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

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


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


   /* Setup response xml body */

   Local XmlDoc &xmlDocResponse;
   &xmlDocResponse = CreateXmlDoc("");

   Local XmlNode &responseRootNode;
   &responseRootNode = &xmlDocResponse.CreateDocumentElement("RESPONSE");


   Local XmlNode &xnTemp;
   Local XmlNode &xnChildNode;
   &xnChildNode = &xmlDocResponse.DocumentElement.AddElement("hello");
   &xnTemp = &xnChildNode.AddText("world");
   &xnChildNode.AddAttribute("DEBUG_NODE", "True");

   &xnChildNode = &xmlDocResponse.DocumentElement.AddElement("STRING_TEST_CDATA");

   Local string &s = "<p><b>I have characters that should be escaped</b></p>";
   &xnTemp = &xnChildNode.AddCDataSection(&s);

   &xnChildNode = &xmlDocResponse.DocumentElement.AddElement("STRING_TEST");
   &xnTemp = &xnChildNode.AddText(&s);

   Local XmlNode &nxMetaNode;
   &nxMetaNode = &xmlDocResponse.DocumentElement.AddElement("META");
   &nxMetaNode.AddAttribute("isMETA", "True");

   &xnTemp = &nxMetaNode.AddElement("OPRID").AddText(%OperatorId);
   &xnTemp = &nxMetaNode.AddElement("CURRENT_TIME").AddText(String(%Datetime));
   &xnTemp = &nxMetaNode.AddElement("TRANSACTION_ID").AddText(&msRequest.TransactionId);
   &xnTemp = &nxMetaNode.AddElement("DBNAME").AddText(%DbName);

   /* Push the generated XML to the response document */
   &response.SetXmlDoc(&xmlDocResponse);
   Return &response;

end-method;
Author Profile
Chris Malek

Chris Malek is a PeopleTools® Technical Consultant with over two decades of experience. He is available for consulting engagements.

Work with Chris
Subscribe to Updates
SWS Bolt-On
PeopleSoft Simple Web Services

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
Read More & Purchase
SWS Bolt-On
PeopleSoft Simple Web Services

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
Read More & Purchase
SWS Bolt-On
PeopleSoft Simple Web Services

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
Read More & Purchase
SWS Bolt-On
PeopleSoft Simple Web Services

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
Read More & Purchase
psLens Platform
psLens Operations & Intelligence

Look up any record, field, page, or component, audit security, and monitor Integration Broker across every database — in seconds.

  • 30+ object types browsable
  • 16 real-time alert types
  • Read-only by design
  • No App Designer or SQL required
Learn More
psLens Platform
psLens Operations & Intelligence

A web console built for the PeopleSoft community — operational monitoring, security auditing, and metadata browsing in one tool.

  • Sub-second object search
  • Catch stuck IB messages before users do
  • Audit service permissions from one screen
  • Works in any browser
Learn More
psLens Platform
psLens Operations & Intelligence

On-demand security and operational reports for your PeopleSoft environment — no client install required.

  • 14 on-demand reports
  • Markdown export for AI/LLM workflows
  • No shared tenancy
  • Built on 25+ years of PeopleSoft expertise
Learn More
psLens Platform
psLens Operations & Intelligence

Research any PeopleSoft object and monitor system health from a single browser tab — no App Designer, no SQL.

  • 30+ PeopleSoft object types browsable
  • Real-time alerts before users report problems
  • Read-only and secure
  • Private alpha — early access now
Learn More