You are on page 1of 10

http://oraclearchworld.wordpress.

com/

SOA Data Validation Framework


By Kathiravan Udayakumar
SOA Data Validation Framework is critical framework; it will define the SOA Foundation for an
Enterprise. This Framework will define principles and guidelines to implement data validation in
Service Integration Layer. In Oracle SOA Suite 11g, Platform Level Data Validation can be forced and
implemented through Service Data Definition (XSD). Schematron aids in business data validation for
XML messages; it can be readily integrated with Oracle SOA Suite Components to facilitate this.
This article will discuss in detail about the Essential Components involved in building this SOA Data
Validation Frameworks and Implementation techniques. Below list of topics will be discussed in
detailed in this article
 Service Data Validation Techniques in Oracle SOA Suite
o Enabling Payload Validation through XSD
o Enabling Data Validation through Schematron
 Schematron Overview
o Integrating Schematron with Oracle SOA Suite
 SOA Data Validation Framework Summary
o Framework Components
o Implementation Techniques

Service Data Validation Techniques in Oracle SOA Suite


Service Data Validation can be enabled through multiple different techniques in Oracle SOA Suite.
This section of the article will discuss in detail about the below stated techniques.
 Enabling Payload Validation through XSD
o Enabling Platform Level Service Data Validation
o Enabling Data Validation in BPEL Variables
o Enabling Data Validation in Mediator
 Enabling Data Validation through Schematron
o Enabling Data validation through Schematron in BPEL
o Enabling Data validation through Schematron in Mediator

Enabling Payload Validation through XSD


As most of the readers are well aware, schema validation can be enabled through XSD. In few
occasions it becomes overhead for the middleware to validate the every payload for the schema
definition; so the platform level controls are provided to turn-on or turn-off the validation. The below
screen shot shows the option to enable or disable the payload validation at platform level and
engine level from SOA Fusion Middleware Console.

Payload validation can also be enabled through BPEL Activity (Validate). The below screenshot
shows the BPEL with Validate activity; desired variables can be validated using this technique.
Validation of the service data can also be enabled through the validateXML Partner Link Property for
request – response scenarios.

Payload validation can be enabled in mediator through the configuration in the routing rule. The
below screenshot shows the Mediator with Validate Syntax; it enables to perform XSD schema
validation for all request and reply messages.
Enabling Data Validation through Schematron
I like to point to the readers that we have technique to validate the data through Schematron.
Details of the Schematron and related information will be presented in the following section of the
article.

Introduction to Schematron
Schematron is an XML based language for making assertions about the presence of data patterns in
XML documents. Schematron can be used for Business rules Validation, Data Reporting and etc.
Schematron is very often it is used as a supplement to strengthen XSD grammars. Schematron is an
ISO standard which has used in many industries, notably the financial sector, governmental record
exchange, and in technical and reference publishing. Schematron can be natively accessed from XSL
document and as it is also supported through XPath Expressions.
The Schematron allows us to develop and mix two kinds of schemas:
1. Report elements allow us to diagnose which variant of a language we are dealing with.
2. Assert elements allow us to confirm that the document conforms to a particular schema.
The Schematron works as stated below.
Step 1: It finds a context nodes in the document (typically an element) based on XPath path criteria;
then,
Step 2: It checks to identify if some other XPath expressions are true, for each of those nodes.
Step 3: It Reports the custom message.
The Schematron can be useful in conjunction with many grammar-based structure-validation
languages: DTDs, XML Schemas, RELAX, TREX, etc.
The Code Snippet shown below describes the Schematron file that is used to validate an Order XML
Data Structure for the data validation rules noted below.
1. Order Service Data should contain at-least one item element.
2. Sum of the item price value should match the Order grant total price.
3. Customer’s billing and shipping address should be mandatory in Order XML Structure.
4. Customer id should be mandatory in the Order XML Structure.
5. More than one customer billing and shipping address should not be present in the Order

Order Schema Definition is shown below for benefit of the readers to understand the details
Schematron file.
Listing A: Order Definition (Order.xsd)
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.org"
targetNamespace="http://www.onlinestore.org/Order"
elementFormDefault="qualified">
<xsd:element name="Order">
<xsd:annotation>
<xsd:documentation>A sample element</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="OrderID"/>
<xsd:element name="OrderDescrtiption"/>
<xsd:element name="TotalOrderValue"/>
<xsd:element name="Items">
<xsd:complexType>
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="Item">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ProductName"/>
<xsd:element name="Price"/>
<xsd:element name="Units"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CustomerDetails">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CustomerID"/>
<xsd:element name="CustomerName"/>
<xsd:element name="CustomerAddress"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="BillToAddress"/>
<xsd:element name="BillToPhone"/>
<xsd:element name="BillToName"/>
<xsd:element name="ShipToAddress"/>
<xsd:element name="ShipToPhone"/>
<xsd:element name="BillToName"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

Listing B: Order Validation Schematron (OrderValidation.sch)


<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<pattern>
<title>Order Data Should have atleast one item element</title>
<rule context="item">
<assert test="count(item) &gt; 0">Order Data Should have atleast one item element</assert>
</rule>
</pattern>
<pattern>
<title>2. Sum of the item price value should match the Order grant total price.</title>
<rule context="item prices">
<assert test="sum(price) &eq; TotalOrderValue">Sum of the item price value should match the Order grant total
price.</assert>
</rule>
</pattern>
<pattern>
<title>Customer’s billing should be mandatory in Order XML Structure.</title>
<rule context="Billing ">
<assert test="count(BillToAddress) &eq; 1">Customer’s billing address should be mandatory and it cannot be more
than one as well.</assert>
</rule>
</pattern>
<pattern>
<title>Customer’s shipping address should be mandatory in Order XML Structure.</title>
<rule context="Shipping Address">
<assert test="count(ShipToAddress) &eq 1">Customer’s shipping address should be mandatory and it cannot be more
than one as well.</assert>
</rule>
</pattern>
<pattern>
<title>Customer id should be mandatory in the Order XML Structure.</title>
<rule context="Customer ID">
<assert test="length(CustomerID) &gt; 1">Customer id should be mandatory in the Order XML Structure.</assert>
</rule>
</pattern>
</schema>

SOA Data Validation Framework Summary


SOA Data Validation Framework is an essential framework that should be considered to be in place
to centralize the data validation. Schema level Data Validation can be enforced through XSD
definition and platform level settings are in place to make it effective, however the business level
validation on the SOA data cannot be enforced using XML Definitions. Schematron can be widely
used to apply the data level validation, beyond XML definition based enforcement on the SOA data.

Problem/Need:
Ability to express the data validation and apply business meaning to its validated results for SOA
Data

Solution Details:
SOA Data Validations can be achieved through Schematron. Business Validation rules can be
centralized suing Schematron files and it can be accessed through Service Layer, Java API or native
XPath. Schematron can also be executed through Ant Scripts but it may not be of great relevance to
SOA.
Framework Component Details
SOA Data Validation Framework contains the WebService API and Schematron Rules. Data Validation
rules will be stored in the Schematron Files and Web Service API will be enabled through SCA Service
Layer for Integration.

Implementation Techniques
Integrating Schematron with Oracle SOA Suite is provided by Mediator. Required number of
validation services can be built using the mediator and it can be called to process the data. In case of
EBS (Enterprise Business Service) or EBF (Enterprise Business Flows ) development; Master
Validation services can be developed using Mediator component to validate the master data to
ensure the validity of the data that is passed through. Below Screenshot shows the options provided
by the mediator configuration to call a Schematron file from Oracle SOA. This would ensure required
service interface is also available through the mediator service components.

You might also like