Here we will see how to accept AnyType Data(xsd:anyType) and convert it into a valid xml data.
Data to be passed as Any type XML string data:
<?xml version="1.0" encoding="UTF-8" ?>
<HREmployeeData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org SOA/Schemas/XMLFormat.xsd" xmlns="http://www.example.org">
<First>testF</First>
<Last>testL</Last>
<Phone>phNo</Phone>
<Income>in</Income>
<Status>Employed</Status>
<JobHistory>
<JobTitle>JT</JobTitle>
<Salary>Sal</Salary>
</JobHistory>
</HREmployeeData>
<?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.example.org" elementFormDefault="qualified">
<xsd:element name="HREmployeeDataIn">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="AnyTypeXMLData" type="xsd:anyType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="HREmployeeDataOut">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="First" type="xsd:string"/>
<xsd:element name="Last" type="xsd:string"/>
<xsd:element name="Phone" type="xsd:string"/>
<xsd:element name="Income" type="xsd:double"/>
<xsd:element name="Status" type="xsd:string"/>
<xsd:element name="JobHistory">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="JobTitle" type="xsd:string"/>
<xsd:element name="Salary" type="xsd:double"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Create the schema say "XMLFormat.xsd" which xml string data to be passed as input to the service.
<?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.example.org" elementFormDefault="qualified">
<xsd:element name="HREmployeeData">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="First" type="xsd:string"/>
<xsd:element name="Last" type="xsd:string"/>
<xsd:element name="Phone" type="xsd:string"/>
<xsd:element name="Income" type="xsd:double"/>
<xsd:element name="Status" type="xsd:string"/>
<xsd:element name="JobHistory">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="JobTitle" type="xsd:string"/>
<xsd:element name="Salary" type="xsd:double"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org"
targetNamespace="http://www.example.org" elementFormDefault="qualified">
<xsd:element name="HREmployeeData">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="First" type="xsd:string"/>
<xsd:element name="Last" type="xsd:string"/>
<xsd:element name="Phone" type="xsd:string"/>
<xsd:element name="Income" type="xsd:double"/>
<xsd:element name="Status" type="xsd:string"/>
<xsd:element name="JobHistory">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="JobTitle" type="xsd:string"/>
<xsd:element name="Salary" type="xsd:double"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Use the Input and Output schema and create a BPEL Service.
Open the BPLE Process and create a variable varXMLTypeData using XMLformat.xsdUse parseXML() function to AnyTypeXMLDATA Input and store in varXMLTypeData variable
Please note that when you are selecting the anyType data, in Assign activity this will not get copied in the expression builder, hence you need to manually add this data.
oraext:parseXML($inputVariable.payload/ns1:AnyTypeXMLData)
Parsing done. Now assign the parsed elements to output elements
Deploy and test
No comments:
Post a Comment