Handling Complex XML Processing in OutSystems: Integration Case Study 

Introduction 

While working on an XML integration requirement in OutSystems, I implemented multiple solutions related to processing large and complex XML files. The XML structure contained nested objects, multiple lists, document metadata, and large binary content, which made the implementation increasingly difficult to maintain and debug. 

Although OutSystems provides extensions for XML processing, handling deeply nested structures and large document data introduced several issues during XML-to-JSON conversion and deserialization. This case study highlights the key technical challenges faced during the implementation, the root causes identified, and the solutions used to build a cleaner, scalable, and more reliable XML processing workflow in OutSystems.1981bf16 6592 4fe2 aed1 6e65207f5f3c 

Project Requirement 

The requirement involved: 

  • Reading and processing large XML files 
  • Extract and store data into multiple entities 
  • Handling deeply nested XML structures 
  • Extracting document information and binary content 
  • Converting XML data into structured entities 
  • Supporting multiple object hierarchies and collections 
  • Ensuring stable deserialization and maintainability 

Initially, the implementation used the OutSystems XML extension directly to read XML nodes and map values into entities. However, as the XML complexity increased, multiple issues started appearing. 

image 1

Case 1: Complex XML Parsing Logic Using XML Extension 

Problem 

OutSystems provides an XML extension for extracting XML node data. While it works well for smaller XML structures, processing highly nested XML files introduced major challenges. 

The XML files contained: 

  • Multiple nested objects 
  • Lists inside objects 
  • Lists inside lists 
  • Deep hierarchical structures 
  • Multiple repeating nodes 

Using only XML extension methods resulted in: 

  • Very long implementation flows 
  • Large numbers of XML node extraction actions 
  • Difficult debugging and maintenance 
  • Reduced readability of server actions 

As the XML structure expanded, maintaining the implementation became increasingly difficult. 

image 1

Solution Architecture 

To simplify the processing logic, I changed the implementation approach completely. 

Instead of manually traversing every XML node: 

New Processing Flow 

  1. Convert XML text into JSON 
  2. Deserialize JSON into OutSystems structures 
  3. Save structured data into entities 

The XML was converted into JSON using the XmlToJson extension. 

image 3

Important Technical Considerations 

Structure Matching 

The OutSystems structure must exactly match the XML/JSON hierarchy. 

Important considerations: 

  • Structure names are case-sensitive 
  • Attribute names must match correctly 
  • Collections must be configured properly 
  • Nested lists must follow the same hierarchy 

Even a small naming mismatch can cause deserialization failures. 

image 2

Benefits of This Approach 

After shifting from manual XML traversal to JSON deserialization: 

  • Logic became significantly cleaner 
  • Debugging became easier 
  • Maintenance effort was reduced 
  • Entity mapping became more structured 
  • Future XML changes became easier to support 

This approach improved both scalability and developer productivity. 

image 5

Case 2: Same Name Conflict During XML to JSON Conversion 

Problem 

One of the XML nodes contained the same name for both the parent node and the inner value: 

“Document”: [“SUM-2016-1215-900089.pdf”] 

However, the structure created in OutSystems expected the value in text format: 

“Document”:”SUM-2016-1215-900089.pdf” 

During deserialization, this mismatch caused runtime failures because OutSystems interpreted the value as an array instead of a single text value. 

Error Impact 

  • JSON deserialization failures 
  • Data mapping interruptions 
  • Increased debugging complexity 
  • Inconsistent behavior across document records 
image 8

Root Cause Analysis 

The issue occurred because the XML to JSON conversion process interpreted the repeated naming pattern as a collection. 

Since both the node and inner value used the same name (Document), the converter automatically wrapped the value inside square brackets ([]) and generated an array. 

image 4

Solution Implemented 

Instead of redesigning all structures and modifying multiple dependent flows, I implemented a targeted preprocessing solution before deserialization. 

The generated JSON text was cleaned using string replacement: 

Replace(Json, ‘”Document”:[“‘, ‘”Document”:”‘) 

The closing array brackets were also removed accordingly. 

image 20
image 6

Result 

After implementing this fix: 

  • JSON deserialization completed successfully 
  • Existing structures remained unchanged 
  • No additional refactoring was required 
  • The solution became stable without impacting other modules 
image 7

Case 3: XmlToJson Failing Due to Large Binary Content 

Problem 

Another critical issue appeared while converting XML files containing binary document data. 

The XML included document nodes containing large encoded binary values. 

When these large values were passed directly into the XmlToJson extension, the conversion process failed repeatedly. 

Observed Issues 

  • XmlToJson conversion failures 
  • Performance degradation 
  • Timeout risks 
  • Increased memory usage 
image 9

Solution Strategy 

To solve this issue, I implemented a preprocessing mechanism to separate binary data before converting the XML into JSON. 

The approach involved extracting binary content first, storing it separately, and removing it temporarily from the XML. 

image 12

Binary Extraction Workflow 

Step 1: Fetch Document Nodes 

The first step was retrieving all document nodes from the XML. 

Actions Used 

  • XmlDocument_SelectNodes 

Inputs 

  • XPathString 
  • XmlDocument 

Output 

  • XmlNodeList (Object Type) 
image 10

Step 2: Count XML Nodes 

The total number of document nodes was identified using: 

  • XmlNodeList_Count 

This count was later used for looping through the nodes. 

image 11

Step 3: Iterate Through XML Nodes 

A manual loop using an index variable was implemented. 

A normal For Each loop could not be used because the XML node list returned an object type. 

Actions Used 

  • XmlNodeList_Item 
  • XmlElement_SelectSingleNode 
  • XmlElement_GetInnerText 

Process 

  1. Retrieve node using index 
  2. Select binary attribute node 
  3. Extract binary value 
  4. Store value inside a structure 

At this stage, all binary data was safely stored separately. 

image 11

Step 4: Remove Binary Content From XML 

Once the binary data was extracted, the original XML node value was cleared. 

Action Used 

  • XmlElement_SetInnerText 

This significantly reduced the XML payload size. 

image 15

Step 5: Save Updated XML 

Finally, the updated XML document was regenerated using: 

  • XmlDocument_Save 

The cleaned XML was then passed into the XmlToJson extension. 

image 19

Since the large binary values had already been removed, the conversion process completed successfully. 

image 18

Final Outcome 

After implementing these improvements: 

Technical Improvements 

  • Stable XML to JSON conversion 
  • Successful deserialization of large XML files 
  • Reduced processing failures 
  • Better memory handling 
  • Cleaner integration logic 
image 13

Development Improvements 

  • Easier maintenance 
  • Reduced implementation complexity 
  • Better scalability for future XML formats 
  • Improved readability of server actions 
  • Faster issue resolution during testing 
image 14

Key Learnings 

This implementation reinforced several important lessons while working with enterprise integrations in OutSystems: 

  • XML parsing logic can become difficult to maintain for deeply nested structures 
  • Converting XML into JSON simplifies deserialization significantly 
  • Binary data should be handled separately during transformation processes 
  • Naming conflicts can create unexpected array behavior during conversion 
  • Provide JSON structure and its attributes names in ‘Name in JSON’ field  570b4184 ec92 4c29 a9b4 03ed42cfdcc2 
  • Small preprocessing fixes can sometimes be more effective than large-scale refactoring 
image 16

Extensions Used 

  • XML Extension 
  • XmlToJson Extension 
image 17

Conclusion 

By optimizing XML preprocessing, JSON conversion, and deserialization handling, I was able to build a cleaner and more scalable XML processing workflow in OutSystems. These improvements simplified debugging, improved maintainability, and increased overall integration stability. 

Visited 14 times, 1 visit(s) today
About Author

Newsletter

Signup our newsletter to get updated information, and insight about the technology

In This Study

    Latest article