Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Shabarish_Nair
Active Contributor
7,409

XML / XSD validations are often common customer requirements. Today, from PI 7.1 and above, SAP offers a standard feature for doing such validations in the Adapter engine or the Integration engine.   To be frank I am disappointed.

The standard feature isnt what I expected it to be.

So what are my complaints?

1. Flexibility - First of all you need to start with uploading the XSD file in some weird location on the file system. Ideally, I would have preferred it to be directly linked from my ESR. if not, at least give me the flexibility to upload it to a preferred location.

2. Error handling - As I understand it, if the validation fails it throws up an alert and the processing stops. But thats not how integration works isnt it? We all need better control on the message flow. What If I want to check if it has failed validation and then instead of the process coming to a halt, continue on further and take some action.

ex. If validation fails, write the input message to an error folder or on failure, send the message back to the sender itself citing the failure reason. 

If you do a simple search on SDN, you will find many blogs around custom solutions on how to do a XML/XSD validation. In this blog I will like to introduce another alternative and extend the options using the JAXB framework.

Using JAXB, we will implement a PI java mapping to do the validation.   

Note: It is not in the scope of this document to explain how the JAXB framework works and I will assume that the reader has the knowledge of using JAXB for XML binding.  

The Prerequisites;

You can access the code and other resources using to implement the validation in this wiki link.    

XSD Structure:

  

All the fields are of string type except 'edition' which is an Integer

Now that we have a control on the validation, we can then thus formulate the  output to suit specific integration needs.  

Case 1: Valid XML structure

Case 2: Invalid XML - Missing Mandatory Node/Fields

In the below, the input XML does not contain the AdditionalInfo node and its fields.


 

Case 3: Invalid XML - Non integer value for field Edition

In the below, the input XML contain a non integer value in the field Edition. This is not correct since the XSD definition states that the field is an integer type


6 Comments