Read file inside BPEL using Xpath function

To read a file in SOA composite, we can use the following options
    1. Using file adapter
    2. Using java embedding
    3. Using xpath function i.e. ora:readFile()

We generally use file adapter to read, write or poll files from different file locations. But, in case if don't want to create a file adapter and don't want to go for java embedding. We can make use of BPEL xpath extension functions. In this article, we will discuss about reading a file using xpath function ora:readFile().

Xpath expression:


xmlns:ora =

'fileName': Refers to absolute path of file along with extension. This is mandatory field. 

'schemaLocation' : Refers to location of nxsd schema for the file to be read. This is an optional field. If you don't provide the schema location, then data from the file will be read and converted to base64 encoded string

'rootElement' : Refers to root element in nxsd schema. This is optional field but required if we provide schema location.


Sample CSV file with absolute file path: C:\Users\test\SOA\test1.csv


Sample NXSD Schema:

<xsd:schema xmlns:xsd="" xmlns:nxsd="" xmlns:tns="" targetNamespace="" elementFormDefault="qualified" attributeFormDefault="unqualified" nxsd:version="NXSD" nxsd:stream="chars" nxsd:encoding="UTF-8" nxsd:hasHeader="true" nxsd:headerLines="1" nxsd:headerLinesTerminatedBy="${eol}">
  <xsd:element name="Root-Element">
        <xsd:element name="row" minOccurs="1" maxOccurs="unbounded">
              <xsd:element name="S.No" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;"/>
              <xsd:element name="Field1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;"/>
              <xsd:element name="Field2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;"/>
              <xsd:element name="Field3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;"/>

Xpath statement without schema, which will give output as base64 schema.


Xpath statement with schema, which will give output as xml

<Root-Element xmlns="">

Using either of the above statements we can read file in assign activity directly, without using file adapter or java embedding.


Post a Comment

Popular posts from this blog

DateTime formatting using xp20:format-dateTime ()

Create Delimited String from XML Nodes and Vice Versa in SOA 12c

Import and Export MDS artifacts in SOA 12c