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.
When providing XML web services from PeopleSoft, your encoding options are:
The psoftToXML class is useful when:
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;
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 ", ¶mEMPLID);
&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>
You can also encode just one record object:
Local Record &recPerson = CreateRecord(Record.PERSON);
&recPerson.EMPLID.Value = ¶mEMPLID;
&recPerson.SelectByKey();
&childNode = &p2XML.RecordToXML(&xmlout.DocumentElement, &recPerson);
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 ", ¶mEMPLID);
&rsPerson2.GetRow(1).GetRowset(Scroll.ADDRESSES).Fill("WHERE EMPLID = :1 ", ¶mEMPLID);
&childNode = &p2XML.RowsetToXML(&xmlout.DocumentElement, &rsPerson2);
This produces nested XML with the PERSON record and all ADDRESS rows as child elements.
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 = ¶mEMPLID;
&recPerson4.SelectByKey();
&childNode = &p2XML.RecordToXML(&xmlout.DocumentElement, &recPerson4);
The excluded fields will not appear in the output.
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 = ¶mEMPLID;
&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, ¶mEMPLID, &recOPR5);
&childNode = &p2XML.RecordToXML(&tempNode, &recOPR5);
This produces XML with PERSON_DATA and SECURITY_DATA as separate parent sections.
The PeopleSoft project is available on GitHub: psoftToXML
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 ChrisSWS turns SQL into production REST APIs — ready for AI, modern apps, and partner integrations. One install, unlimited potential.
A powerful PeopleSoft bolt-on that makes REST web services easy. You bring the SQL, SWS handles the rest.
Traditional PeopleSoft web services cost $3,600–$13,000 each to develop. SWS deploys production REST APIs in under 5 minutes through configuration alone.
Turn PeopleSoft data into clean REST APIs for AI integrations, modern applications, and vendor data feeds. Configuration-driven — no PeopleCode required.