Contents

PsoftToXML Application Class

The psoftToXML Application Class converts PeopleSoft objects (Rowsets, Rows, Records) to XML for use in web services. It serves as an alternative to Rowset-based messages, providing more flexibility in organizing the output while still leveraging standard PeopleSoft data objects.

Why Use This?

When providing XML web services from PeopleSoft, your encoding options are:

  • PeopleCode XML class - Create bespoke XML documents manually. Required when clients need a specific XML structure.
  • Rowset-based messages - Let PeopleSoft handle the encoding. The XML structure is tightly coupled to the record structures.
  • psoftToXML - A middle ground that encodes PeopleSoft objects to XML dynamically, with some flexibility over what gets included.

The psoftToXML class is useful when:

  • You are providing raw PeopleSoft data to a 3rd party that can handle the PeopleSoft data structure
  • You want to avoid maintaining a bunch of Rowset-based messages every time you add a new table to an export
  • You need dynamic content where a Rowset-based message is tied to a specific record

Class Signature

class psoftToXML
   method RowsetToXML(&parentNode As XmlNode, &rowSetIn As Rowset) Returns XmlNode;
   method RecordToXML(&parentNode As XmlNode, &recordIn As Record) Returns XmlNode;
   method FieldToXML(&ParentNode As XmlNode, &fieldIn As Field) Returns XmlNode;
   method RowToXML(&ParentNode As XmlNode, &rowIn As Row) Returns XmlNode;
   method psoftToXML();
   property array of string fieldsToSkip;
end-class;

Import: import CHG_XML:psoftToXML;

Example 1 - Return Person Rowset

Encode a rowset with the PERSON record for one person:

&response = CreateMessage(Operation.CHG_PERSON_GET, %IntBroker_Response);

Local CHG_XML:psoftToXML &p2XML = create CHG_XML:psoftToXML();

Local XmlDoc &xmlout;
Local XmlNode &childNode;

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

Local Rowset &rsPerson = CreateRowset(Record.PERSON);

&rsPerson.Fill("WHERE EMPLID = :1 ", &paramEMPLID);
&childNode = &p2XML.RowsetToXML(&xmlout.DocumentElement, &rsPerson);

&response.SetXmlDoc(&xmlout);

Output:

<?xml version="1.0"?>
<response>
    <PERSON PSOBJECTTYPE="ROWSET">
        <ROW PSOBJECTTYPE="ROW" RowNumber="1">
            <PERSON PSOBJECTTYPE="RECORD">
                <EMPLID PSFIELDTYPE="CHAR" PSOBJECTTYPE="FIELD">L00013</EMPLID>
                <BIRTHDATE PSFIELDTYPE="DATE" PSOBJECTTYPE="FIELD">1950-04-01</BIRTHDATE>
                <BIRTHCOUNTRY PSFIELDTYPE="CHAR" PSOBJECTTYPE="FIELD">USA</BIRTHCOUNTRY>
                <LAST_CHILD_UPDDTM PSFIELDTYPE="DATETIME" PSOBJECTTYPE="FIELD">2009-04-14-10.26.08.000000</LAST_CHILD_UPDDTM>
            </PERSON>
        </ROW>
    </PERSON>
</response>

Example 2 - Encode a Single Record

You can also encode just one record object:

Local Record &recPerson = CreateRecord(Record.PERSON);
&recPerson.EMPLID.Value = &paramEMPLID;
&recPerson.SelectByKey();

&childNode = &p2XML.RecordToXML(&xmlout.DocumentElement, &recPerson);

Example 3 - Nested Rowsets

The RowsetToXML method recursively encodes child rowsets. In this example, we create a PERSON -> ADDRESSES hierarchy:

Local Rowset &rsPerson2 = CreateRowset(Record.PERSON, CreateRowset(Record.ADDRESSES));
&rsPerson2.Fill("WHERE EMPLID = :1 ", &paramEMPLID);
&rsPerson2.GetRow(1).GetRowset(Scroll.ADDRESSES).Fill("WHERE EMPLID = :1 ", &paramEMPLID);

&childNode = &p2XML.RowsetToXML(&xmlout.DocumentElement, &rsPerson2);

This produces nested XML with the PERSON record and all ADDRESS rows as child elements.

Example 4 - Excluding Fields

You can exclude fields by pushing field names to the fieldsToSkip array. This is useful for fields that are sensitive or you don’t want to expose to a client:

&p2XML.fieldsToSkip.Push("DT_OF_DEATH");
&p2XML.fieldsToSkip.Push("BIRTHDATE");

Local Record &recPerson4 = CreateRecord(Record.PERSON);
&recPerson4.EMPLID.Value = &paramEMPLID;
&recPerson4.SelectByKey();
&childNode = &p2XML.RecordToXML(&xmlout.DocumentElement, &recPerson4);

The excluded fields will not appear in the output.

Example 5 - Custom XML Structure

All encoding methods take an XML parent node as a parameter, so you can organize the output under different XML elements:

Local Record &recPerson5 = CreateRecord(Record.PERSON);
&recPerson5.EMPLID.Value = &paramEMPLID;
&recPerson5.SelectByKey();

Local XmlNode &tempNode;

&tempNode = &xmlout.DocumentElement.AddElement("PERSON_DATA");
&childNode = &p2XML.RecordToXML(&tempNode, &recPerson5);

&tempNode = &xmlout.DocumentElement.AddElement("SECURITY_DATA");
Local Record &recOPR5 = CreateRecord(Record.PSOPRDEFN);
SQLExec("%selectall(:1) WHERE PSOPRDEFN.EMPLID = :2", &recOPR5, &paramEMPLID, &recOPR5);
&childNode = &p2XML.RecordToXML(&tempNode, &recOPR5);

This produces XML with PERSON_DATA and SECURITY_DATA as separate parent sections.

Getting the Code

The PeopleSoft project is available on GitHub: psoftToXML


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