Skip Headers
Oracle® Application Server Adapters for Files, FTP, Databases, and Enterprise Messaging User's Guide
10g Release 2 (10.1.2.)
B25307-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

2 Oracle Application Server Adapter for Files/FTP

This chapter describes how to use the Oracle Application Server Adapter for Files/FTP (file and FTP adapters), which work in conjunction with Oracle BPEL Process Manager as an external service. References to use cases for the file and FTP adapters are also provided.

This chapter contains the following topics:


Note:

The term Oracle Application Server Adapter for Files/FTP is used for the file and FTP adapters, which are separate adapters with very similar functionality.

Introduction to the File and FTP Adapters

Oracle BPEL Process Manager includes the file and FTP adapters. The file and FTP adapters enable your BPEL process to exchange (read and write) files on local file systems and remote file systems (through use of the file transfer protocol (FTP)). The file contents can be both XML and non-XML data formats.

This section contains the following topics:

File and FTP Adapter Features

The file and FTP adapters enable you to configure your BPEL process to interact with local and remote file system directories. The file and FTP adapters can read and write the following file formats and use the adapter translator component at both design time and run time:

  • XML (both XSD- and DTD-based)

  • Delimited

  • Fixed positional

  • Binary data

  • COBOL Copybook data

The file and FTP adapters can also treat file contents as an opaque object and pass the contents in their original format (without performing translation). The opaque option handles binary data such as JPGs and GIFs whose structure cannot be captured in an XSD or data you do not want to have translated.

The translator enables the file and FTP adapters to convert native data in various formats to XML, and vice versa. The native data can be simple (just a flat structure) or complex (with parent-child relationships).

The FTP adapter supports the use of secure FTP on Solaris.

The file and FTP adapters exchange files in the inbound and outbound directions. Based on the direction, the file and FTP adapters perform a different set of tasks.

For inbound files sent to Oracle BPEL Process Manager, the file and FTP adapters perform the following operations:

  • Poll the file system looking for matches

  • Read and translate the file contents based on the translation logic defined at design time

  • Publish the same as an XML message

This functionality of the file and FTP adapters is referred to as the file read operation and the component that provides this function as the file reader. This operation is known as a Java Connector Architecture (JCA) inbound interaction.

For outbound files sent from Oracle BPEL Process Manager, the file and FTP adapters perform the following operations:

  • Receive messages from BPEL

  • Format the XML contents as specified at design time

  • Produce output files

This functionality of the file and FTP adapters is referred to as the file write operation and the component that provides this functionality as the file writer. This operation is known as a JCA outbound interaction.

For the inbound and outbound directions, the file and FTP adapters use a set of configuration parameters. For example:

  • The inbound file and FTP adapters have parameters for the inbound directory where the input file appears and the frequency with which to poll the directory.

  • The outbound file and FTP adapters have parameters for the outbound directory in which to write the file and the file naming convention to use.

The file reader supports polling conventions and offers several postprocessing options. After processing the file, the files can be deleted, moved to a directory, or left as is. The file reader can split the contents of a file and publish it in batches, instead of as a single message. This feature can be utilized for performance tuning of the file and FTP adapters. The file reader guarantees once and once-only delivery.

When a file contains multiple messages, you can select to publish messages in a specific number of batches. This is referred to as debatching. During debatching, the file reader, upon restart, proceeds from where it left off in the previous run, thereby avoiding duplicate messages.

The file writer offers several conditions for output file creation. The output files can be created based on time elapsed, file size, and number of messages received.

See the following sections for details about the read and write functionality of the file and FTP adapters:

File and FTP Adapter Architecture

The file and FTP adapters are based on JCA 1.5 architecture. JCA provides a standard architecture for integrating heterogeneous enterprise information systems (EIS). The adapter framework of the file and FTP adapters exposes the underlying JCA interactions as services (WSDL with JCA binding) for Oracle BPEL Process Manager integration. See Oracle Application Server Adapter Concepts for details about OracleAS Adapter architecture.

File and FTP Adapter Integration with Oracle BPEL Process Manager

The file and FTP adapters are automatically integrated with Oracle BPEL Process Manager. When you create a partner link in JDeveloper BPEL Designer, you can invoke the Adapter Configuration Wizard, as shown in Figure 1-2.

This wizard enables you to select and configure the file and FTP adapters or other OracleAS Adapters, as shown in Figure 1-3. The Adapter Configuration Wizard then prompts you to enter a service name, as shown in Figure 1-4. When configuration is complete, a WSDL file of the same name is created in the Applications Navigator section of JDeveloper BPEL Designer. This WSDL file contains the configuration information you specify with the Adapter Configuration Wizard.

After specifying a service name (as shown in Figure 1-4), you are prompted to select an operation to perform. Based on your selection, different Adapter Configuration Wizard windows appear and prompt you for configuration information. Table 2-1 lists the available operations and provides references to sections that describe the configuration information you must provide.

Table 2-1 Supported Operations

Operation See Section...

File Adapter

-

  • Read File (inbound operation)

"File Adapter Read File Concepts"


  • Write File (outbound operation)

"File Adapter Write File Concepts"


FTP Adapter

-

  • Get File (inbound operation)

"FTP Adapter for Get File Concepts"


  • Put File (outbound operation)

"FTP Adapter for Put File Concepts"



See Oracle Application Server Adapter Concepts for more information about OracleAS Adapter integration with Oracle BPEL Process Manager.

File and FTP Adapter Concepts

This section contains the following topics:

File Adapter Read File Concepts

In the inbound direction, the file adapter polls and reads files from a file system for processing. This section provides an overview of the inbound file reading capabilities of the file adapter. You use the Adapter Configuration Wizard to configure the file adapter for use with your BPEL process. This creates an inbound WSDL file named after the service name you specify with the Adapter Configuration Wizard. An inbound header file named fileAdapterInboundheader.wsdl is also created.

This section contains the following topics:

Inbound Operation

For inbound operations with the file adapter, you select to perform an inbound Read File operation. Figure 2-1 shows this selection.

Figure 2-1 Selecting the Read File Operation

Description of Figure 2-1  follows
Description of "Figure 2-1 Selecting the Read File Operation"

Inbound File Directory Specifications

The File Directories window of the Adapter Configuration Wizard shown in Figure 2-2 enables you to specify information about the directory to use for reading inbound files and the directories in which to place successfully processed files.

Figure 2-2 Adapter Configuration Wizard—Specifying Incoming Files

Description of Figure 2-2  follows
Description of "Figure 2-2 Adapter Configuration Wizard—Specifying Incoming Files"

The following sections describe the file directory information to specify:

Specifying Inbound Physical or Logical Directory Paths

You can specify inbound directory names as physical or logical paths. Physical paths are values such as c:\inputDir.

Logical properties are specified in the inbound WSDL file and their logical-physical mapping is resolved using partner link properties. You specify the logical parameters once at design time, and you can later modify the physical directory name as needed.

Provide a logical name. For example, the generated inbound WSDL file looks as follows for the logical input directory name InputFileDir.

<operation name="Read">
   <jca:operation
      LogicalDirectory="InputFileDir"
      ActivationSpec="oracle.tip.adapter.file.inbound.FileActivationSpec"
      IncludeFiles=".*"
      PollingFrequency="5"
      MinimumAge="0"
      DeleteFile="true"
      OpaqueSchema="true" >
   </jca:operation>

In the BPEL partner link of the bpel.xml file, you then provide the physical parameter values (in this case, the directory path) of the corresponding logical ActivationSpec or InteractionSpec. This resolves the mapping between the logical directory name and actual physical directory name.

<?xml version = '1.0' encoding = 'UTF-8'?>
<BPELSuitcase>
  <BPELProcess id="ComplexStructure" src="ComplexStructure.bpel">
    <partnerLinkBindings>
      <partnerLinkBinding name="InboundPL">
        <property name="wsdlLocation">ComplexStructureInbound.wsdl</property>
      </partnerLinkBinding>
      <partnerLinkBinding name="OutboundPL">
        <property name="wsdlLocation">ComplexStructureOutbound.wsdl</property>
      </partnerLinkBinding>
    </partnerLinkBindings>
      <activationAgents>
      <activationAgentclassName=
"oracle.tip.adapter.fw.agent.jca.JCAActivationAgent"partnerLink="InboundPL">
      <property name="InputFileDir">C:/ora_home/integration/bpm/samples/tutorials/
121.FileAdapter/ComplexStructure/InputDir/</property>
      <property name="portType">Read_ptt</property>
    </activationAgent>
   </activationAgents>
  /BPELProcess>
</BPELSuitcase>

Note:

Multiple BPEL processes or multiple file adapters polling one inbound directory are not supported. Ensure that all are polling their own unique directory.

Archiving Successfully Processed Files

This option enables you to specify a directory in which to place successfully processed files. You can also specify the archive directory as a logical name. In this case, you must follow the logical-to-physical mappings described in "Specifying Inbound Physical or Logical Directory Paths".


Note:

Files greater than or equal to 7 MB cannot be delivered. As an alternative, debatch large files (if they have multiple messages), and publish these files in messages of sizes less than 7 MB.

File Matching and Batch Processing

The File Filtering window of the Adapter Configuration Wizard shown in Figure 2-3 enables you to specify details about the files to retrieve or ignore.

The file adapter acts as a file listener in the inbound direction. The file adapter polls the specified directory on a local or remote file system and looks for files that match a specified naming criteria.

Figure 2-3 Adapter Configuration Wizard—File Filtering

Description of Figure 2-3  follows
Description of "Figure 2-3 Adapter Configuration Wizard—File Filtering"

The following sections describe the file filtering information to specify:

Specifying a Naming Pattern

Specify the naming convention that the file adapter uses to poll for inbound files. You can also specify the naming convention for files you do not want to process. Two naming conventions are available for selection. The file adapter matches the files that appear in the inbound directory.

  • File wildcards (po*.txt)

    Retrieves all files that start with po and end with .txt. This convention conforms to Windows operating system standards.

  • Regular expressions (po.*\.txt)

    Retrieves all files that start with po and end with .txt. This convention conforms to Java Development Kit (JDK) regular expression (regex) constructs.


Notes:

  • If you later select a different naming pattern, ensure that you also change the naming conventions you specify in the Include Files and Exclude Files fields. The Adapter Configuration Wizard does not automatically make this change for you.

  • Do not specify *.* as the convention for retrieving files.

  • Be aware of any file length restrictions imposed by your operating system. For example, Windows operating system file names cannot be more than 256 characters in length (the filename, plus the complete directory path). Some operating systems also have restrictions on the use of specific characters in file names. For example, Windows operating systems do not allow characters like \, /, :, *, <, >, or |.


Including and Excluding Files

If you use regular expressions, the values you specify in the Include Files and Exclude Files fields must conform to JDK regular expression (regex) constructs. For both fields, different regex patterns must be provided separately. The Include Files and Exclude Files fields correspond to the IncludeFiles and ExcludeFiles parameters, respectively, of the inbound WSDL file.


Note:

The regex pattern complies with the JDK regex pattern. According to the JDK regex pattern, the correct connotation for a pattern of any characters with any number of occurrences is a period followed by a plus sign (.+). An asterisk (*) in a JDK regex is not a placeholder for a string of any characters with any number of occurrences.

If you want the inbound file adapter to pick up all file names that start with po and which have the extension txt, you must specify the Include Files field as po.*\.txt when the name pattern is a regular expression. In this regex pattern example:

  • A period (.) indicates any character

  • An asterisk (*) indicates any number of occurrences

  • A backslash followed by a period (\.) indicates the character period (.), as indicated with the backslash escape character

The Exclude Files field is constructed similarly.

If you have Include Files field and Exclude Files field expressions that have an overlap, the exclude files expression takes precedence. For example, if Include Files is set to abc*.txt and Exclude Files is set to abcd*.txt, you receive any files prefixed with abcd*.

Table 2-2 lists details of Java regex constructs.


Note:

Do not begin JDK regex pattern names with the following characters: +, ?, or *.

Table 2-2 Java Regular Expression Constructs

Matches Construct

Characters

-

The character x

x

The backslash character

\\


The character with octal value 0n (0 <= n <= 7)

\0n

The character with octal value 0nn (0 <= n <= 7)

\0nn

The character with octal value 0mnn (0 <= m <= 3, 0 <= n <= 7)

\0mnn

The character with hexadecimal value 0xhh

\xhh

The character with hexadecimal value 0xhhhh

\uhhhh

The tab character ('\u0009')

\t

The newline (line feed) character ('\u000A')

\n

The carriage-return character ('\u000D')

\r

The form-feed character ('\u000C')

\f

The alert (bell) character ('\u0007')

\a

The escape character ('\u001B')

\e

The control character corresponding to x

\cx

-

-

Character classes

-

a, b, or c (simple class)

[abc]

Any character except a, b, or c (negation)

[^abc]

a through z or A through Z, inclusive (range)

[a-zA-Z]

a through d, or m through p: [a-dm-p] (union)

[a-d[m-p]]

d, e, or f (intersection)

[a-z&&[def]]

a through z, except for b and c: [ad-z] (subtraction)

[a-z&&[^bc]]

a through z, and not m through p: [a-lq-z](subtraction)

[a-z&&[^m-p]]

-

-

Predefined character classes

-

Any character (may or may not match line terminators)

-

A digit: [0-9]

\d

A nondigit: [^0-9]

\D

A whitespace character: [ \t\n\x0B\f\r]

\s

A nonwhitespace character: [^\s]

\S

A word character: [a-zA-Z_0-9]

\w

A nonword character: [^\w]

\W

Greedy quantifiers

-

X, once or not at all

X?

X, zero or more times

X*

X, one or more times

X+

X, exactly n times

X{n}

X, at least n times

X{n,}

X, at least n, but not more than m times

X{n,m}


For details about Java regex constructs, go to

http://java.sun.com/j2se/1.4.2/docs/api
Batching Multiple Inbound Messages

You can select if incoming files have more than one message, and specify the number of messages in one batch file to publish. When a file contains multiple messages and this check box is selected, this is referred to as debatching. Nondebatching is when the file contains only a single message and the check box is not selected.

File Polling

The File Polling window of the Adapter Configuration Wizard shown in Figure 2-4 enables you to specify the following inbound polling parameters:

  • The frequency with which to poll the inbound directory for new files to retrieve.

  • The minimum file age of files to retrieve. For example, this enables a large file to be completely copied into the directory before it is retrieved for processing. The age is determined by the last modified time stamp. For example, if you know that it takes three to four minutes for a file to be written, set the minimum age of pollable files to five minutes. If a file is detected in the input directory and its modification time is less than 5 minutes older than the current time, the file is not retrieved because it is still potentially being written to.

  • Whether or not to delete files after a successful retrieval. If this check box is not selected, processed files remain in the inbound directory, but are ignored. Only files with modification dates more recent than the last processed file are retrieved. If you place another file in the inbound directory with the same name as a file that has already been processed, but the modification date remains the same, that file is not retrieved.

Figure 2-4 Adapter Configuration Wizard—File Polling

Description of Figure 2-4  follows
Description of "Figure 2-4 Adapter Configuration Wizard—File Polling"

File Processing

The file adapter prepares the files for processing and delivers them to the adapter translator for translation and debatching (if necessary).

If you have many inbound files to process or very large files of more than 1 MB, you may need to increase the config timeout value in the Oracle_Home\integration\orabpel\system\appserver\oc4j\j2ee\home\server.xml file:

<transaction-config timeout="30000"/>

Postprocessing

The file adapter supports several postprocessing options. After processing the file, the files can be deleted if specified in the File Polling window shown in Figure 2-4. Files can also be moved to a completion (archive) directory if specified in the File Directories window shown in Figure 2-2.

Native Data Translation

The next Adapter Configuration Wizard window that appears is the Messages window shown in Figure 2-5. This window enables you to select the XSD schema file for translation.

Figure 2-5 Specifying the Schema

Description of Figure 2-5  follows
Description of "Figure 2-5 Specifying the Schema"

If native format translation is not required (for example, a JPG or GIF image is being processed) select the Native format translation is not required check box. The file is passed through in base-64 encoding.

XSD files are required for translation. If you want to define a new schema or convert an existing data type description (DTD) or COBOL Copybook, select Define Schema for Native Format. This starts the Native Format Builder Wizard. This wizard guides you through the creation of a native schema file from file formats such as comma-separated value (CSV), fixed-length, DTD, and COBOL Copybook. After the native schema file is created, you are returned to this Messages window with the Schema File URL and Schema Element fields filled in. See "Creating Native Schema Files with the Native Format Builder Wizard" for more information.


Note:

Ensure that the schema you specify includes a namespace. If your schema does not have a namespace, an error message appears.

Error Handling

The file adapter provides several inbound error handling capabilities:

rejectedMessageHandlers Property

You can configure your BPEL process to process the correct records of a file and write only the rejected records to an archive directory by setting the rejectedMessageHandlers property. For example, assume that you have a file with four records. If three records are processed successfully and one record is not, the file is processed with the three correct records. The record that errored is written to a rejected messages directory. The behavior of the rejectedMessageHandlers property in case a file has only one message is to reject the entire message.

You first define the rejectedMessageHandlers property as an activationAgent property in the bpel.xml file so that it applies to inbound WSDL operations only:

<BPELSuitcase>
  <BPELProcess src="ErrorTest.bpel" id="ErrorTest">
    <activationAgents>
       <activationAgent
          className="oracle.tip.adapter.fw.agent.jca.JCAActivationAgent"
                        partnerLink="inboundPL">
         <property name="rejectedMessageHandlers">
            file://C:/orabpel/samples/test/errorTest/rejectedMessages
         </property>

This causes messages that error to be written to the configured directory using the following naming pattern:

fatalErrorFailoverProcess Property

If the file adapter (or any OracleAS Adapter) encounters an unrecoverable system error (such as no more memory or a full disk), it can instruct the adapter framework to shut down the BPEL process.

You can optionally configure a standby (or failover) BPEL process to be invoked when the adapter initiates the shutdown request of the (main) BPEL process.

You configure this failover BPEL process by setting the fatalErrorFailoverProcess property as an activationAgent property in the bpel.xml file.

<property name="fatalErrorFailoverProcess"> bpel://bpel-domain:password|process-name|operation-name|
input-message-part-name
</property>

where password (which can be omitted if it is bpel) can be encrypted.

For example:

<property name="fatalErrorFailoverProcess">

  bpel://default|JCA-FatalErrorHandler|handleError|message
</property>

or

<property name="fatalErrorFailoverProcess"> 
 bpel://default:C23487CFA591952D3ED0B81F0961F65A|JCA-FatalErrorHandler|handleError|message</property>

where the bpel password was specified in encrypted form (using the encrypt.bat (for Windows) or encrypt.sh (for UNIX) command line utility).

The fatal error BPEL process must use a specific input (WSDL) message type. This message type is defined in the system-provided WSDL file FatalErrorMessageWSDL.wsdl. This WSDL can be referenced (imported) using the following:

<import namespace="http://xmlns.oracle.com/pcbpel/fatalErrorHandler"         location="http://localhost:9700/orabpel/xmllib/jca/FatalErrorMessage.wsdl"/>

The XML schema type for this message is as follows:

<complexType name="FatalErrorMessageType">
  <sequence>
    <element name="Reason" type="string"/>
    <element name="Exception" type="string"/>
    <element name="StackTrace" type="string"/>
  </sequence>
</complexType>

The purpose of the failover BPEL process can be to undertake error compensating actions, alert someone through e-mail or short message service (SMS), or restart some other process.

uniqueMessageSeparator Property

In the case of debatching (multiple messages in a single file), the typical behavior is to reject the messages from the first bad message to the end of the file. If each message has a unique separator and that separator is not part of any data, then rejection can be more fine-grained. In these cases, you can define a uniqueMessageSeparator in the schema element of the native schema to have the value of this unique message separator. This property controls how the adapter translator works when parsing through multiple records in one file (debatching). This property enables recovery even when detecting bad messages inside a large batch file; when a bad record is detected, the adapter translator skips to the next unique message separator boundary and continues from there. If you do not set this property, all records that follow the record that errored are also rejected.

The following schema file provides an example of using uniqueMessageSeparator.

<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
            targetNamespace="http://TargetNamespace.com/Reader"
            xmlns:tns="http://TargetNamespace.com/Reader"
            elementFormDefault="qualified" attributeFormDefault="unqualified"
            nxsd:encoding="US-ASCII" nxsd:stream="chars" 
            nxsd:version="NXSD" nxsd:uniqueMessageSeparator="${eol}">
  <xsd:element name="emp-listing">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="emp" minOccurs="1" maxOccurs="unbounded">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="GUID" type="xsd:string" nxsd:style="terminated"
                           nxsd:terminatedBy="," nxsd:quotedBy="&quot;">
              </xsd:element>
              <xsd:element name="Designation" type="xsd:string"
                           nxsd:style="terminated" nxsd:terminatedBy=","
                           nxsd:quotedBy="&quot;">
              </xsd:element>
              <xsd:element name="Car" type="xsd:string" nxsd:style="terminated"
                           nxsd:terminatedBy="," nxsd:quotedBy="&quot;">
              </xsd:element>
              <xsd:element name="Labtop" type="xsd:string"
                           nxsd:style="terminated" nxsd:terminatedBy=","
                           nxsd:quotedBy="&quot;">
              </xsd:element>
              <xsd:element name="Location" type="xsd:string"
                           nxsd:style="terminated" nxsd:terminatedBy=","
                           nxsd:quotedBy="&quot;">
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
<!--NXSDWIZ:D:\work\jDevProjects\Temp_BPEL_process\Sample2\note.txt:-->
<!--USE-HEADER:false:-->
Default Error Directory

If you do not set the rejectedMessageHandlers property, records that error during translation are placed by default in

Oracle_Home\integration\orabpel\domains\domain_name\archive\jca\default_directory

Guaranteed Delivery and Recovery from Server Failures

The file adapter guarantees once-only delivery of inbound files. This includes guaranteed delivery of large files through FTP. If your system goes down, the read functionality of the file adapter upon restart avoids creating duplicate messages.

If your system server crashes while inbound messages are being processed, you must manually perform recovery when the server restarts to ensure that all message records are recovered. For example, a file has ten messages and the server crashes after three messages have been processed. This causes the fourth message to go undelivered. When the server restarts and begins processing with message five (the offset of the last successfully rejected message), you must manually recover message four to ensure that all messages are preserved.

Perform the following procedures to recover the rejected message record.

  1. Log in to Oracle BPEL Console.

  2. Select the BPEL Processes tab.

  3. Click Perform Manual Recovery under the Related Tasks section.

  4. Click Recover.

Inbound Service Name WSDL File

When you finish configuring the file adapter, a WSDL file is generated for the inbound direction. The file is named after the service name you specified on the Service Name window of the Adapter Configuration Wizard shown in Figure 1-4. You can rerun the wizard at any time to change your operation definitions.

The ActivationSpec parameter holds the inbound configuration information. The ActivationSpec and a set of inbound file adapter properties are part of the inbound WSDL file.

The inbound WSDL contains the following information:

<pc:inbound_binding />
  <operation name="Read">
    <jca:operation
      ActivationSpec="oracle.tip.adapter.file.inbound.FileActivationSpec"
      PhysicalDirectory="C:/ora_home/integration/bpm/samples/tutorials/121.FileAdapter/ComplexStructure/inputDir/"
      PhysicalArchiveDirectory="C:/ora_home/integration/bpm/samples/tutorials/121.FileAdapter/ComplexStructure/archiveDir/"
      IncludeFiles=".+\.txt"
      PollingFrequency="5"
      MinimumAge="0"
      DeleteFile="true"
      OpaqueSchema="false" >
    </jca:operation>
    <input>
      <jca:header message="hdr:InboundHeader_msg" part="inboundHeader"/>
    </input>
  </operation>
</binding>

The ActivationSpec parameters are specified in the Adapter Configuration Wizard during design time and appear in the binding element of the inbound WSDL. The inbound file adapter uses the following configuration parameters:

  • PollingFrequency

    This parameter specifies how often to poll a given input directory for new files. The parameter is of type int and is mandatory. The default value is 1 minute.

  • PhysicalDirectory

    This parameter specifies the physical input directory to be polled. The parameter is of type String. The inbound directory where the files appear is mandatory. You must specify the physical directory or logical directory.

  • LogicalDirectory

    This parameter specifies the logical input directory to be polled. The parameter is of type String.

  • PublishSize

    This parameter indicates if the file contains multiple messages, and how many messages to publish to the BPEL process at a time. The parameter is of type int and is not mandatory. The default value is 1.

  • PhysicalArchiveDirectory

    This parameter specifies where to archive successfully processed files. The parameter is of type String and is not mandatory.

  • LogicalArchiveDirectory

    This parameter specifies the logical directory in which to archive successfully processed files. The parameter is of type String and is not mandatory.

  • IncludeFiles

    This parameter specifies the pattern for types of files to pick up during polling. The parameter is of type String and is not mandatory.

  • ExcludeFiles

    This parameter specifies the pattern for types of files to be excluded during polling. The parameter is of type String and is not mandatory.

Inbound Header WSDL File

The WSDL file shown in "Inbound Service Name WSDL File" includes two attributes that indicate which message and part define the operation headers:

<jca:header message="hdr:InboundHeader_msg" part="inboundHeader"/>

The fileAdapterInboundHeader.wsdl file defines these attributes. This file also provides information such as the name of the file being processed and its directory path. This file is created along with the service name WSDL file, and displays in the Applications Navigator of JDeveloper BPEL Designer.

<definitions
     name="fileAdapter"
     targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/" 
     xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/file/"   
     xmlns="http://schemas.xmlsoap.org/wsdl/" >
    <types>
        <schema attributeFormDefault="qualified" elementFormDefault="qualified" 
                targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/"
                xmlns="http://www.w3.org/2001/XMLSchema" 
                xmlns:FILEAPP="http://xmlns.oracle.com/pcbpel/adapter/file/">
          <element name="InboundFileHeaderType">
                <complexType>
                    <sequence>
                        <element name="fileName" type="string"/>
                        <element name="directory" type="string"/>
                    </sequence>
                </complexType>
            </element> 
        </schema>
    </types>
   
    <!-- Header Message --> 
    <message name="InboundHeader_msg"> 
      <part element="tns:InboundFileHeaderType" name="inboundHeader"/> 
   </message> 
</definitions>

See the online Help that is included with the Adapter tab in JDeveloper BPEL Designer for more information.

Synchronous File Reading Capabilities

The file adapter can synchronously read a file using an invoke activity. If the specified file does not exist, the read invoke activity returns nothing. You must manually edit the WSDL file to enable this functionality.

  1. Create a WSDL file for the write file operation using the Adapter Configuration Wizard.

  2. Select the schema of the file to be read in the Adapter Configuration Wizard Messages window.

  3. Change the value of the parameters in the <jca:operation> element section of the created WSDL file to:

    InteractionSpec = oracle.tip.adapter.file.outbound.FileReadInteractionSpec
    PhysicalDirectory=Directory_from_which_to_read
    FileName=file_name_to_read
    DeleteFile=true | false
    
    

    where either true or false is selected for the DeleteFile parameter. Do not use a regular expression for the FileName parameter value. For synchronous reads, the file name must be known.

  4. Review the operation section of the WSDL file, which includes information similar to the following:

    <operation name="Write">
    <input message="..."/>
    </operation>
    
    
  5. Rename the input message to output message. The adapter uses this to return the translated file contents. This now points to the native format definition you created with the Adapter Configuration Wizard.

  6. Create an empty_msg message type:

    <element name="empty"><complexType/></element>
    
    
  7. Add an input message to the <operation> pointing to an empty element as defined in step 6.

  8. Modify the <invoke> activity in the BPEL file with appropriate inputVariable (pointing to the empty_msg type) and outputVariable attributes.

    A sample WSDL section looks as follows. Note that the dots (...) in the following example represent areas you must complete with information appropriate to your environment.

    <types><schema xmlns="http://www.w3.org/2001/XMLSchema"targetNamespace="..."><import..../><element name="empty"><complexType/></element> </schema></types><message name="Address-List_msg"> /* The output message */<part name="..." element="...:.."/></message><message name="Empty_msg"><part name="Empty" element="...:empty"/></message><portType name="SynchronousRead_ptt"><operation name="SynchronousRead"><input message="tns:Empty_msg"/><output message="tns:Address-List_msg"/></operation></portType><binding name="SynchronousRead_binding" type="tns:SynchronousRead_ptt"><jca:binding /><operation name="SynchronousRead"><jca:operation PhysicalDirectory="D:\work\jDevProjects"InteractionSpec="oracle.tip.adapter.file.outbound.FileReadInteractionSpec"FileName="address_csv.txt"DeleteFile="true"OpaqueSchema="false" ></jca:operation>
    

File Adapter Write File Concepts

In the outbound direction, the file adapter receives messages from the BPEL process and writes the messages to a file in a file system. This section provides an overview of the outbound file writing capabilities of the file adapter. You use the Adapter Configuration Wizard to configure the file adapter for use with your BPEL process. This creates an outbound WSDL file named after the service name you specify with the Adapter Configuration Wizard. An outbound header file named fileAdapterOutboundheader.wsdl is also created.

This section contains the following topics:

Outbound Operation

For outbound operations with the file adapter, you select to perform an outbound Write File operation. Figure 2-6 shows this selection.

Figure 2-6 Selecting the Write File Operation

Description of Figure 2-6  follows
Description of "Figure 2-6 Selecting the Write File Operation"

Outbound File Directory Creation

For the outbound operation, you can specify the outbound directory, outbound file naming convention to use and, if necessary, the batch file conventions to use.

The File Configuration window of the Adapter Configuration Wizard shown in Figure 2-7 enables you to specify the directory for outgoing files and the outbound file naming convention.

Figure 2-7 Adapter Configuration Wizard—Parameters for Outgoing Files

Description of Figure 2-7  follows
Description of "Figure 2-7 Adapter Configuration Wizard—Parameters for Outgoing Files"

The following sections describe the file configuration information to specify:

Specifying Outbound Physical or Logic Directory Paths

You can specify outbound directory names as physical or logical paths. Physical paths are values such as c:\outputDir.

If you specify logical parameters, the generated WSDL file looks as follows for the logical outbound directory name OutputFileDir.

<jca:binding />
  <operation name="Write">
    <jca:operation
      InteractionSpec="oracle.tip.adapter.file.outbound.FileInteractionSpec"
      LogicalDirectory="OutputFileDir"
      FileNamingConvention="po_%SEQ%.xml">
    </jca:operation>
  .....

In the BPEL partner link in the bpel.xml file, you then specify an outbound partner link binding property through the Property tab of the partner link. This resolves the mapping between the logical directory name and the actual physical directory name.

<?xml version = '1.0' encoding = 'UTF-8'?>
<BPELSuitcase>
  <BPELProcess id="ComplexStructure" src="ComplexStructure.bpel">
    <partnerLinkBindings>
      <partnerLinkBinding name="InboundPL">
        <property name="wsdlLocation">ComplexStructureInbound.wsdl</property>
      </partnerLinkBinding>
    <partnerLinkBinding name="OutboundPL">
      <property name="wsdlLocation">ComplexStructureOutbound.wsdl</property>
      <property name="OutputFileDir">C:/ora_home/integration/bpm/samples/tutorials/ 
121.FileAdapter/ComplexStructure/outputDir/</property> 
  </partnerLinkBinding>
</partnerLinkBindings>
    <activationAgents>
    <activationAgentclassName=
"oracle.tip.adapter.fw.agent.jca.JCAActivationAgent"partnerLink="InboundPL">
    <property name="portType">Read_ptt</property>
   </activationAgent>
  </activationAgents>
 </BPELProcess>
</BPELSuitcase>

Note:

Ensure that you limit the length of outbound file names (the file name, plus the complete directory path) to 200 characters. This is not an exact limit, but rather a recommendation. When an outbound file name is long (for example, 215 characters), a blank file with that name is created in the outbound directory.

Specifying the Outbound File Naming Convention

Specify the naming convention to use for outgoing files. You cannot enter completely static names such as po.txt. This is to ensure the uniqueness of outgoing files names, which prevents files from being inadvertently overwritten. Instead, outgoing file names must be a combination of static and dynamic portions.

The prefix and suffix portions of the file example shown in Figure 2-7 are static (for example, po_ and .xml). The %SEQ% variable of the name is dynamic and can be a sequence number or a time stamp (for example, po_%yyMMddHHmmss%.xml to create a file with a time stamp).

The sequence number is written to a file if the system goes down. If you choose a name starting with po_, followed by a sequence number and the extension txt as the naming convention of the outgoing files, then you must specify po_%SEQ%.txt.

If you choose a name starting with po_, followed by a time stamp with pattern yyyy.MM.dd and the extension txt as the naming convention of the outgoing file, then you must specify po_%yyyy.MM.dd%.txt. For example, the outgoing file name can be po_2004.11.29.txt.

You cannot use a regular expression for outbound synchronous reads. In these cases, the exact file name must be known.

A time stamp is specified by date and time pattern strings. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. The characters "''" represent a single quote. All other characters are not interpreted.

The Java pattern letters are defined in Table 2-3.

Table 2-3 Java Pattern Letters

Letter Date or Time Component Presentation Examples

G

Era designator

Text

AD

y

Year

Year

1996; 96

M

Month in year

Month

July; Jul; 07

w

Week in year

Number

27

W

Week in month

Number

2

D

Day in year

Number

189

d

Day in month

Number

10

F

Day of week in month

Number

2

E

Day in week

Text

Tuesday; Tue

a

AM/PM marker

Text

PM

H

Hour in day (0-23)

Number

0

k

Hour in day (1-24)

Number

24

K

Hour in AM/PM (0-11)

Number

0

h

Hour in AM/PM (1-12)

Number

12

m

Minute in hour

Number

30

s

Second in minute

Number

55

S

Millisecond

Number

978

z

Time zone

General Time Zone

Pacific Standard Time; PST; GMT-08:00

Z

Time zone

RFC 822 Time Zone

-0800


Different presentations in the pattern are as follows:

  • Text

    For formatting, if the number of pattern letters is four or more, the full form is used; otherwise, a short or abbreviated form is used if available. For parsing, both forms are accepted, independent of the number of pattern letters.

  • Number

    For formatting, the number of pattern letters is the minimum number of digits, and shorter numbers are zero-padded to this amount. For parsing, the number of pattern letters is ignored unless it is needed to separate two adjacent fields.

  • Year

    For formatting, if the number of pattern letters is two, the year is truncated to two digits; otherwise, it is interpreted as a number.

For parsing, if the number of pattern letters is more than two, the year is interpreted literally, regardless of the number of digits. Using the pattern MM/dd/yyyy, 01/11/12 parses to Jan 11, 12 A.D.

For parsing with the abbreviated year pattern (y or yy), the abbreviated year is interpreted relative to some century. The date is adjusted to be within 80 years before and 20 years after the time instance is created. For example, using a pattern of MM/dd/yy and Jan 1, 1997 is created; the string 01/11/12 is interpreted as Jan 11, 2012, while the string 05/04/64 is interpreted as May 4, 1964. During parsing, only strings consisting of exactly two digits are parsed into the default century. Any other numeric string, such as a one-digit string, a three-or-more-digit string, or a two-digit string that is not all digits (for example, -1), is interpreted literally. So 01/02/3 or 01/02/003 is parsed, using the same pattern, as Jan 2, 3 AD. Likewise, 01/02/-3 is parsed as Jan 2, 4 BC.

  • Month

    If the number of pattern letters is 3 or more, the month is interpreted as text; otherwise, it is interpreted as a number.

  • General time zone

    Time zones are interpreted as text if they have names. For time zones representing a GMT offset value, the following syntax is used:

GMTOffsetTimeZone:
      GMT Sign Hours : Minutes
   Sign: one of
      + -
   Hours:
      Digit
      Digit Digit
   Minutes:
      Digit Digit
   Digit: one of
      0 1 2 3 4 5 6 7 8 9

Hours must be between 0 and 23, and Minutes must be between 00 and 59. The format is locale-independent and digits must be taken from the Basic Latin block of the Unicode standard.

For parsing, RFC 822 time zones are also accepted.

For formatting, the RFC 822 4-digit time zone format is used:

RFC822TimeZone:
      Sign TwoDigitHours Minutes
   TwoDigitHours:
      Digit Digit

TwoDigitHours must be between 00 and 23. Other definitions are the same as for general time zones.

For parsing, general time zones are also accepted.

Specifying a Dynamic Outbound File Name

You can also use variables to specify dynamic outbound file names through use of the OutboundHeader_msg message name in the fileAdapterOutboundHeader.wsdl.

<definitions
     name="fileAdapter"
     targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/"
     xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/file/"
     xmlns="http://schemas.xmlsoap.org/wsdl/" >
    <types>
        <schema attributeFormDefault="qualified" elementFormDefault="qualified"
                targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/"
                xmlns="http://www.w3.org/2001/XMLSchema"
                xmlns:FILEAPP="http://xmlns.oracle.com/pcbpel/adapter/file/">
            <element name="OutboundFileHeaderType">
                <complexType>
                    <sequence>
                        <element name="fileName" type="string"/>
                    </sequence>
                </complexType>
            </element>
        </schema>
    </types>
    <!-- Header Message -->
    <message name="OutboundHeader_msg">
      <part element="tns:OutboundFileHeaderType" name="outboundHeader"/>
   </message>
</definitions> 

Create a variable of message type OutboundHeader_msg, assign it a value, and use it in the Adapter tab of an invoke activity. For example:

 <variables>
      <variable name="fileHeader" messageType="file:OutboundHeader_msg"/>
    [..]

    <assign>
      <copy>
        <from>*testfile.txt*</from>
        <to variable="fileHeader" part="outboundHeader"
            query="/file:OutboundFileHeaderType/file:fileName"/>
      </copy>
    </assign>     <invoke name="FileSend" partnerLink="outboundPL"
             portType="out:FileWrite_PortType" operation="Write"
             inputVariable="payload"
    bpelx:inputHeaderVariable="fileHeader"/> 

See the online Help that is included with the Adapter tab in JDeveloper BPEL Designer for more information.

Batching Multiple Outbound Messages

In the simplest scenario, you specify writing a single file to a single message. You can also specify the outbound method for batch file writing. This enables you to specify the number of messages in one batch file to publish. The following batch file settings are provided in the File Configuration window shown in Figure 2-7:

  • Number of messages equals

    Specify a value that, when equaled, causes a new outgoing file to be created.

  • Elapsed time exceeds

    Specify a time that, when equaled, causes a new outgoing file to be created.

  • File size exceeds

    Specify a file size that, when equaled, causes a new outgoing file to be created. For example, assume you specify a value of three for the number of messages received and a value of 1 MB for the file size. When you receive two messages that when combined equal or exceed 1 MB, or three messages that are less than 1 MB, an output file is created.

If the file adapter goes down during batching, it starts batching at the point at which it left off upon recovery.

Native Data Translation

The next Adapter Configuration Wizard window that appears is the Messages window shown in Figure 2-8. This window enables you to select the XSD schema file for translation.

Figure 2-8 Specifying the Schema

Description of Figure 2-8  follows
Description of "Figure 2-8 Specifying the Schema"

As with specifying the schema for the inbound direction, you can perform the following tasks in this window:

  • Specify if native format translation is not required

  • Select the XSD schema file for translation

  • Start the Native Format Builder Wizard to create an XSD file from file formats such as CSV, fixed-length, DTD, and COBOL Copybook

See "Native Data Translation" for more information about the Messages window.

Error Handling

As with inbound files, the file adapter guarantees once-only delivery of outbound files. This includes guaranteed delivery of large files through FTP. If your system goes down, the write functionality of the file adapter upon restart has the knowledge to proceed from where it left off in the previous run, thereby avoiding duplicate messages. If the target host is unavailable, the file adapter supports retrying to send documents. For example, if the directory to which it is trying to write is read only, the file adapter tries to write again. You must configure two partner link retry properties from the Property tab of the partner link (updates the bpel.xml file):

<partnerLinkBinding name="WriteFile">
  <property name="wsdlLocation">WriteFile.wsdl</property>
  <property name="retryMaxCount">10</property>
  <property name="retryInterval">60</property>

The write operation eventually succeeds (if the problem is resolved in a timely fashion). If the problem is not resolved within the retry period, a binding fault is sent back to the BPEL process.

Outbound Service Name WSDL File

When you complete configuration of the file adapter with the Adapter Configuration Wizard, a WSDL file is generated for the outbound direction. The file is named after the service name you specified on the Service Name window of the Adapter Configuration Wizard shown in Figure 1-4. You can rerun the wizard at any time to change your operation definitions.

The InteractionSpec parameters in the WSDL file contain the outbound configuration information that you specified with the Adapter Configuration Wizard during design time. The InteractionSpec parameters and a set of outbound file adapter properties are part of the outbound WSDL file. The outbound WSDL includes the following information:

<jca:binding />
  <operation name="Write">
    <jca:operation
      InteractionSpec="oracle.tip.adapter.file.outbound.FileInteractionSpec"
      PhysicalDirectory="C:/ora_home/integration/bpm/samples/tutorials/121.FileAdapter/ComplexStructure/outputDir/"
      FileNamingConvention="po_%SEQ%.xml"
      NumberMessages="1"
      ElapsedTime="60"
      FileSize="1000000"
      OpaqueSchema="false" >
    </jca:operation>
    <input>
      <jca:header message="hdr:OutboundHeader_msg" part="outboundHeader"/>
    </input>
  </operation>
</binding>

The outbound file adapter uses the following configuration parameters:

  • PhysicalDirectory

    This parameter specifies the physical directory in which to write output files. The parameter is of type String. The outbound directory where the outgoing files are written is mandatory. You must specify the physical directory or logical directory.

  • LogicalDirectory

    This parameter specifies the logical directory in which to write output files. The parameter is of type String.

  • NumberMessages

    This parameter is used for outbound batching. The outgoing file is created when the number of messages condition is met. The parameter is of type String and is not mandatory. The default value is 1.

  • ElapsedTime

    This parameter is used for outbound batching. When the time specified elapses, the outgoing file is created. The parameter is of type String and is not mandatory. The default value is 1 minute.

  • FileSize

    This parameter is used for outbound batching. The outgoing file is created when the file size condition is met. The parameter is of type String and is not mandatory. The default value is 1000 kb.

  • FileNamingConvention

    This parameter is for the naming convention for the outbound write operation file. The parameter is of type String and is mandatory.

Outbound Header WSDL File

The WSDL file shown in "Outbound Service Name WSDL File" includes two attributes that indicate which message and part define the operation headers:

<jca:header message="hdr:OutboundHeader_msg" part="outboundHeader"/>

The fileAdapterOutboundHeader.wsdl file defines these attributes, as well as information about the outbound file name. This file is created along with the service name WSDL file, and displays in the Applications Navigator of JDeveloper BPEL Designer.

<definitions
     name="fileAdapter"
     targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/" 
     xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/file/"   
     xmlns="http://schemas.xmlsoap.org/wsdl/" >
    <types>        <schema attributeFormDefault="qualified" elementFormDefault="qualified" 
                targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/"
                xmlns="http://www.w3.org/2001/XMLSchema" 
                xmlns:FILEAPP="http://xmlns.oracle.com/pcbpel/adapter/file/">
            <element name="OutboundFileHeaderType">
                <complexType>
                    <sequence>
                        <element name="fileName" type="string"/>
                    </sequence>
                </complexType>
            </element>  
        </schema>
    </types>
   
    <!-- Header Message --> 
    <message name="OutboundHeader_msg"> 
      <part element="tns:OutboundFileHeaderType" name="outboundHeader"/> 
   </message> 
</definitions>

FTP Adapter for Get File Concepts

In the inbound direction, the FTP adapter works the same as the Read File operations of the file adapter in that it polls and gets files from a file system for processing. The major difference is that the FTP adapter is used for remote file exchanges. Because of this, the Adapter Configuration Wizard asks for connection information to an FTP server to be used later, as shown in Figure 2-9.

Figure 2-9 Specifying FTP Server Connection Information

Description of Figure 2-9  follows
Description of "Figure 2-9 Specifying FTP Server Connection Information"

To create the FTP server connection that you specify in Figure 2-9, you must edit the Oracle_Home\integration\orabpel\system\appserver\oc4j\j2ee\home\application-deployments\default\FtpAdapter\oc4j-ra.xml deployment descriptor file for adapter instance JNDI name and FTP server connection information. A sample of oc4j-ra.xml is as follows:

<?xml version="1.0"?>
<!DOCTYPE oc4j-connector-factories PUBLIC "-//Oracle//DTD Oracle Connector
  9.04//EN" "http://xmlns.oracle.com/ias/dtds/oc4j-connector-factories-9_04.dtd">

<oc4j-connector-factories>
    <connector-factory location="eis/Ftp/FtpAdapter" connector-name="FTP Adapter">
        <config-property name="host" value="stada55.us.oracle.com"/>
        <config-property name="port" value="21"/>
        <config-property name="username" value="anonymous"/>
        <config-property name="password" value="password"/>
    </connector-factory>
</oc4j-connector-factories>

The adapter instance JNDI name is specified as eis/Ftp/FtpAdapter and connection information such as host, port, username, and password are provided as configuration properties.


Notes:

  • The directory path to the oc4j-ra.xml file shown in preceding example is for the BPEL Process Manager for Developers installation type. If you selected the BPEL Process Manager for OracleAS Middle Tier installation type, this file is located in:

    Oracle_Home\j2ee\OC4J_BPEL\application-deployments\default\
    FtpAdapter
    
    
  • The FTP adapter does not support the FTP commands RESTART and RECOVERY during the transfer of large files.


After logging in, you select the Get File (read) operation and the type of file to deliver. Figure 2-10 shows this selection.

Figure 2-10 Selecting the Get File Operation

Description of Figure 2-10  follows
Description of "Figure 2-10 Selecting the Get File Operation"

For inbound and outbound binary file transfers, the Oracle_Home\integration\orabpel\system\appserver\oc4j\j2ee\home\connectors\FtpAdapter\FtpAdapter\META-INF\ra.xml file includes a serverLineSeparator property. This property is automatically used to determine line separators when you transfer data in binary mode only.

<config-property-name>serverLineSeparator</config-property-name> 
<config-property-type>java.lang.String</config-property-type> 
<config-property-value>\n</config-property-value>

This property is not used when transferring data in ASCII mode. This is because in ASCII mode, the line separators are determined by the operating system on which the FTP server is running.

From this point onward, the windows of the Adapter Configuration Wizard window for the Get File operation are the same as those for the Read File operation of the FTP adapter. Table 2-4 lists the windows that display and provides references to sections that describe their functionality.

Table 2-4 Adapter Configuration Wizard Windows for Get File Operation

Window See Section...

File Directories (Figure 2-2)

"Inbound File Directory Specifications"


File Filtering (Figure 2-3)

"File Matching and Batch Processing"


File Polling (Figure 2-4)

"File Polling"


Messages (Figure 2-5)

"Native Data Translation"



An additional Adapter Configuration Wizard window is also available for advanced users. This window is shown in Figure 2-11 and only appears after you make either or both of the following selections on the File Polling window shown in Figure 2-4:

  • Do not select the Delete files after successful retrieval check box.

  • Set the value of the Minimum File Age field to a value greater than 0.

Figure 2-11 File Modification Time

Description of Figure 2-11  follows
Description of "Figure 2-11 File Modification Time"

This window enables you to specify one of the following methods for obtaining the modification time of files on the remote FTP server:

  • File System

    This option enables you to obtain the date/time format of the file modification time with the file system listing command. However, this option is rarely used and not supported by all FTP servers. See your FTP server documentation to determine whether your server supports the file system listing command, which command line syntax to use, and how to interpret the output.

    For example, if the file system listing command quote mdtm filename is supported and returns the following information:

    213 20050602102633
    
    

    specify the start index, end index, and date/time format of the file modification time in the Data/Time Format field as a single value separated by commas (for example, 4,18,yyyyMMddHHmmss).

    Where:

    • 4 is the start index of the file modification time.

    • 18 is the end index of the file modification time.

    • yyyyMMddHHmmss is the data/time format of the file modification time obtained with the quote mdtm filename command.

    The resulting service_name.wsdl file includes the following parameters and values:

    FileModificationTime="FileSystem"
    ModificationTimeFormat="4,18,yyyyMMddHHmmss"
    
    

    To handle the time zone issue, you must also be aware of the time stamp difference. The time zone of the FTP server is determined by using the Windows date/time properties (for example, by double-clicking the time showing in the Windows task bar). You must then convert the time difference between the FTP server and the system on which the FTP adapter is running to milliseconds and add the value as a property in the bpel.xml file:

    <activationAgents> 
      <activationAgent ...> 
        <property name="timestampOffset">2592000000</property>
    
    
  • Directory Listing

    This option enables you to obtain the date/time format from the file modification time with the FTP directory listing command. For example, if the directory listing command (ls -l) returns the following information:

    12-27-04  07:44AM                 2829 NativeData2.txt
    
    

    specify the start index, end index, and date/time format of the file modification time as a single value separated by commas in either the Old File Date/Time Format field or the Recent File Date/Time Format field (for example, 0,17, MM-dd-yy hh:mma).

    Where:

    • 0 is the start index of the file modification time.

    • 17 is the end index of the file modification time.

    • MM-dd-yy hh:mma is the data/time format of the file modification time obtained with the ls -l command. For this example, the value is entered in the Recent File Date/Time Format field. This field indicates that the format is obtained from the most recent file adhering to the naming convention, whereas the Old File Date/Time Format field obtains the format from the oldest file.

    The resulting service_name.wsdl file includes the following parameters and values:

    FileModificationTime="DirListing"
    ModificationTimeFormat="0,17, MM-dd-yy hh:mma"
    
    

    To handle the time zone issue, you must also be aware of the time stamp difference. The time zone of the FTP server is determined by using the Windows date/time properties (for example, by double-clicking the time showing in the Windows task bar). You must then convert the time difference between the FTP server and the system on which the FTP adapter is running to milliseconds and add the value as a property in the bpel.xml file:

    <activationAgents> 
      <activationAgent ...> 
        <property name="timestampOffset">2592000000</property>
    
    
  • File Name Substring

    This option enables you to obtain the modification time from the file name. For example, if the name of the file is fixedLength_20050324.txt, you can specify the following values:

    • The start index in the Substring Begin Index field (for example, 12).

    • The end index in the End Index field (for example, 20).

    • The date and time format in the Date/Time Format field conforming to the Java SimpleDateFormat to indicate the file modification time in the file name (for example, yyyyMMdd).

    The resulting service_name.wsdl file includes the following parameters and values:

    FileModificationTime="Filename"
    FileNameSubstringBegin="12"
    FileNameSubstringEnd="20"
    ModificationTimeFormat="yyyyMMdd"
    
    

When the Adapter Configuration Wizard completes, configuration files are created in the Applications Navigator section of JDeveloper BPEL Designer.

The inbound service WSDL file name that is created is also similar to that of the file adapter. The main differences include the operation type and the file type.

<pc:inbound_binding />
   <operation name="Get">
<jca:operation
   FileType="binary"

The inbound header WSDL file named ftpAdapterInboundHeader.wsdl looks as follows:

<definitions
     name="fileAdapter"
     targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/ftp/"
     xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/ftp/"  
     xmlns="http://schemas.xmlsoap.org/wsdl/" >
    <types>        <schema attributeFormDefault="qualified" elementFormDefault="qualified"
                targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/ftp/"
                xmlns="http://www.w3.org/2001/XMLSchema"
                xmlns:FTPAPP="http://xmlns.oracle.com/pcbpel/adapter/ftp/">
            <element name="InboundFTPHeaderType">
                <complexType>
                    <sequence>
                        <element name="fileName" type="string"/>
                        <element name="ftpHost" type="string"/>
                        <element name="ftpPort" type="string"/>
                     </sequence>
                </complexType>
            </element>
        </schema>
    </types>
  
    <!-- Header Message -->
    <message name="InboundHeader_msg">
      <part element="tns:InboundFTPHeaderType" name="inboundHeader"/>
   </message>
</definitions>

See "Error Handling" and "Guaranteed Delivery and Recovery from Server Failures" for more information about error handling and guaranteed delivery capabilities.

FTP Adapter for Put File Concepts

In the outbound direction, the FTP adapter works the same as the Write File operations of the file adapter in that it receives messages from the BPEL process and writes the messages in a file to a file system (in this case, remote). Because of this, the Adapter Configuration Wizard prompts you to connect to the FTP server with the adapter instance JNDI name, as shown in Figure 2-9.

After logging in, you select the Put File (write) operation and the type of file to deliver. Figure 2-12 shows this selection.

Figure 2-12 Selecting the Put File Operation

Description of Figure 2-12  follows
Description of "Figure 2-12 Selecting the Put File Operation"

From this point onward, the windows of the Adapter Configuration Wizard window for the Put File operation are the same as those for the Write File operation of the file adapter. Table 2-5 lists the windows that display and provides references to sections that describe their functionality.

Table 2-5 Adapter Configuration Wizard Windows for Put File Operation

Window See Section...

File Configuration (Figure 2-7)

"Outbound File Directory Creation"


Messages (Figure 2-8)

"Native Data Translation"



When the Adapter Configuration Wizard completes, configuration files are created in the Applications Navigator section of JDeveloper BPEL Designer.

The outbound service WSDL file name that is created is also similar to that of the file adapter. The main differences include the operation type and the file type.

<pc:inbound_binding />
   <operation name="Put">
<jca:operation
   FileType="binary"

The outbound header WSDL file named ftpAdapterOutboundHeader.wsdl looks as follows:

<definitions
     name="fileAdapter"
     targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/ftp/"
     xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/ftp/"  
     xmlns="http://schemas.xmlsoap.org/wsdl/" >
    <types>
        <schema attributeFormDefault="qualified" elementFormDefault="qualified"
                targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/ftp/"
                xmlns="http://www.w3.org/2001/XMLSchema"
                xmlns:FTPAPP="http://xmlns.oracle.com/pcbpel/adapter/ftp/">
            <element name="OutboundFTPHeaderType">
                <complexType>
                    <sequence>
                        <element name="fileName" type="string"/>
                    </sequence>
                </complexType>
            </element>
        </schema>
    </types>
  
    <!-- Header Message -->
    <message name="OutboundHeader_msg">
      <part element="tns:OutboundFTPHeaderType" name="outboundHeader"/>
   </message>
</definitions>

See "Error Handling" for more information about error handling capabilities.

Using Secure FTP with the FTP Adapter

The FTP adapter supports the use of the secure FTP feature on Solaris. This section provides an overview of secure FTP functionality and describes how to install and configure this feature.

This section contains the following tasks:


Note:

The FTP adapter supports the secure FTP feature on Solaris only.

Secure FTP Overview

In environments in which sensitive data is transferred to remote servers (for example, sending credit card information to HTTP servers), the issue of security is very important. Security in these cases primarily refers to two requirements:

  • Trust in the remote server with which you are exchanging data

  • Protection from third parties trying to intercept the data

Secure socket layer (SSL) certificates and encryption focus on satisfying these two security requirements. When SSL is used in the context of FTP, the resulting security mechanism is known as FTPS (or FTP over SSL).

To gain the trust of clients in SSL environments, servers obtain certificates (typically, X.509 certificates) from recognized certificate authorities. When you set up the FTP server vsftpd in "Installing and Configuring vsftpd", you use openSSL to create a certificate for the server. Every client trusts a few parties to begin. If the server is one of these trusted parties, or if the server's certificate was issued by one of these parties, you have established trust, even indirectly. For example, if the server's certificate was issued by authority A, which has a certificate issued by authority B, and the client trusts B, that is good enough. For the setup shown in Figure 2-3, the server's certificate is directly imported into the client's certificate store (or Oracle Wallet) as a trusted certificate.

Figure 2-13 Establishing Trust

Description of Figure 2-13  follows
Description of "Figure 2-13 Establishing Trust"

You make the data being transferred immune to spying by encrypting it before sending it and decrypting it after receiving it. Symmetric encryption (using the same key to encrypt and decrypt data) is much faster for large amounts of data than the public key and private key approach. Symmetric encryption is the approach used by FTPS. However, before the client and server can use the same key to encrypt and decrypt data, they must agree on a common key. This is typically done by the client performing the following tasks:

  • Generating a session key (to be used to encrypt and decrypt data)

  • Encrypting this session key using the server's public key that is part of the server's certificate

  • Sending the key to the server

The server decrypts this session key using its private key and subsequently uses it to encrypt file data before sending it to the client.

The remaining subsections describe how to install and configure secure FTP.

Installing and Configuring OpenSSL

OpenSSL is an open source implementation of the SSL protocol. OpenSSL implements basic cryptographic functions and provides utility functions. Install and configure OpenSSL on the Solaris host to use as the FTP server.

  1. Go to the following URL:

    http://www.openssl.org/source
    
    
  2. Locate openssl-0.9.7g.tar.gz in the list of available files. For example:

     3132217 Apr 11 17:21:51 2005 openssl-0.9.7g.tar.gz (MD5) (PGP sign)
    
    
  3. Download the following files:

    • openssl-0.9.7g.tar.gz

    • openssl-0.9.7g.tar.gz.md5 (under the MD5 link)

    • openssl-0.9.7g.tar.gz.asc (under the PGP sign link

  4. Unzip the following file using gunzip.

    gunzip openssl-0.9.7g.tar.gz
    
    
  5. Untar the following file:

    tar xvf openssl-0.9.7g.tar
    
    
  6. Change directories to the following location:

    cd openssl-0.9.7g
    
    
  7. Run the following command:

    ./config --prefix=/usr --openssldir=/usr/local/openssl
    
    
  8. Change to the Bourne shell (if not already using it):

    sh
    
    
  9. Configure and export the PATH:

    PATH=${PATH}:/usr/ccs/bin; export PATH 
    
    
  10. Run the following command:

    make
    
    
  11. Exit the Bourne shell:

    exit
    
    
  12. Run the following command:

    make test
    
    
  13. Log in as the super user:

    msu
    
    
  14. Enter the password when prompted.

  15. Run the following command:

    make install
    

Installing and Configuring vsftpd

The vsftpd server is a secure and fast FTP server for UNIX systems. Install and configure vsftpd on the Solaris host to use as the FTP server.

  1. Go to the following location:

    ftp://vsftpd.beasts.org/users/cevans/
    
    
  2. Download vsftpd-2.0.3 (you need the tar and signature file (.asc file)). For example:

    [BINARY]     vsftpd-2.0.3.tar.gz. . . . . . . . . . .    [Mar 19 21:26]    149K
    [FILE]       vsftpd-2.0.3.tar.gz.asc. . . . . . . . .    [Mar 19 21:26]    189B
    
    
  3. Unzip the following file using gunzip.

    gunzip vsftpd-2.0.3.tar.gz
    
    
  4. Unzip the tar file:

    tar xvf vsftpd-2.0.3.tar
    
    
  5. Change directories to the following location:

    cd vsftpd-2.0.3
    
    
  6. Make the following change in the builddefs.h file:

    #undef VSF_BUILD_SSL
    
    

    to

    #define VSF_BUILD_SSL
    
    
  7. Log in as the super user:

    msu
    
    
  8. Enter the password when prompted.

  9. Create a file named vsftpd.conf with the following settings in the /etc directory:

    # Standalone mode
    listen=YES
    max_clients=200
    max_per_ip=4
    # Access rights
    anonymous_enable=YES
    #chroot_local_user=YES
    #userlist_enable=YES
    ftp_username=ftp
    local_enable=YES
    write_enable=YES
    anon_upload_enable=YES
    anon_mkdir_write_enable=YES
    anon_other_write_enable=YES
    chown_uploads=YES
    chown_username=ftp
    # Security
    anon_world_readable_only=NO
    allow_anon_ssl=YES
    ssl_enable=YES
    connect_from_port_20=YES
    hide_ids=YES
    pasv_min_port=50000
    pasv_max_port=60000
    # Features
    ftpd_banner="Welcome to the FTP Service"
    xferlog_enable=YES
    ls_recurse_enable=NO
    ascii_download_enable=NO
    async_abor_enable=YES
    # Performance
    one_process_model=NO
    idle_session_timeout=120
    data_connection_timeout=300
    accept_timeout=60
    connect_timeout=60
    anon_max_rate=50000
    
    

    Note:

    Copies of the vsftpd.conf file appear in several locations in the vsftpd-2.0.3 directory structure. If you use one of those files to create the vsftpd.conf file in the /etc directory, ensure that it only includes the parameters and settings described in Step 9.

  10. Run the following commands:

    mkdir /var/ftp
    useradd -d /var/ftp ftp
    chown root /var/ftp
    chmod og-w /var/ftp 
    mkdir /usr/share/empty
    mkdir /usr/share/ssl 
    mkdir /usr/share/ssl/certs 
    
    
  11. Run the following command:

    openssl req -x509 -nodes -newkey rsa:1024 -keyout /usr/share/ssl/certs/vsftpd.pem -out /usr/share/ssl/certs/vsftpd.pem
    
    
  12. Run the vsftpd daemon from the vsftpd-2.0.3 directory:

    ./vsftpd
    

Creating an Oracle Wallet

Oracle Wallet Manager is an application for managing and editing security credentials in Oracle wallets. A wallet is a password-protected container that stores authentication and signing credentials, including private keys, certificates, and trusted certificates, all of which are used by SSL for strong authentication.

  1. Create a new wallet in Oracle Wallet Manager.

  2. Import vsftpd.pem from step 11 as a trusted certificate in this wallet.

  3. Save this wallet in PKCS # 12 (.p12) format.

See the Oracle Application Server Administrator's Guide for details about using Oracle Wallet Manager.

Setting Up the FTP Adapter

  1. Perform the following tasks on your Solaris host:

    mkdir /var/ftp/inDir 
    mkdir /var/ftp/outDir 
    chmod 777 /var/ftp/inDir /var/ftp/outDir
    
    
  2. Specify the FTP connection parameters in the FTP adapter oc4j-ra.xml file. The location of this file is based on the installation type you selected.

    • If you selected BPEL Process Manager for Developers, edit the Oracle_Home\integration\orabpel\system\appserver\oc4j\j2ee\home\application-deployments\default\FtpAdapter\oc4j-ra.xml file.

    • If you selected BPEL Process Manager for OracleAS Middle Tier, edit the Oracle_Home\j2ee\OC4J_BPEL\application-deployments\default\FtpAdapter\oc4j-ra.xml file.

    A sample oc4j-ra.xml is as follows:

    <connector-factory location="eis/Ftp/FtpAdapter" connector-name="FTP Adapter">
      <config-property name="host" value="usunnbf29.us.oracle.com"/>
      <config-property name="port" value="21"/> 
      <config-property name="username" value="ftp"/> 
      <config-property name="password" value="password"/>
      <config-property name="useFtps" value="true"/> 
      <config-property name="walletLocation" value="D:\wallet\ewallet.p12"/>
      <config-property name="walletPassword" value="welcome1"/> 
      <config-property name="channelMask" value="both"/> 
      <config-property name="securePort" value="990"/>
    </connector-factory>
    
    
    Where... Is...
    useFtps Set to true. This setting is required to use FTP over SSL. The default is false.
    walletLocation The location of the wallet created in "Creating an Oracle Wallet"
    walletPassword The password of the wallet
    channelMask The type of channel: control channel or data channel. Possible values are both, control, data, or none. The default is both.
    securePort The port for FTP over SSL. The default is 990.

  3. Restart Oracle BPEL Server after changing the oc4j-ra.xml file.

    You have now installed and configured secure FTP and are ready to use this feature with the FTP adapter.

Use Cases for the File and FTP Adapters

Oracle BPEL Process Manager includes a number of demonstrations of file and FTP adapters. Some of these demonstrations are described in Readme files. Others are described in the Oracle BPEL Process Manager documentation set. This section provides an overview of these demonstrations and a reference to documentation that more fully describes the scenarios.

This section contains the following topics:

File Adapter Use Cases

This section provides an overview of file adapter demonstrations.

This section contains the following topics:

File Reading

Several file reading demonstrations are available:

  • A complex structure demonstration shows how to use the file read and write functionality of the file adapter. For a demonstration of a complex structure, go to

    Oracle_Home\integration\orabpel\samples\tutorials\121.FileAdapter\
    ComplexStructure
    
    
  • A simple file reading demonstration is provided as part of a larger tutorial that guides you through the design and execution of a sophisticated process that uses synchronous and asynchronous services, parallel flows of execution, conditional branching logic, fault handling and exceptions management, transformations, the file adapter, the database adapter, and human workflow, notification, and sensor functionality. In the file reading portion, you configure the file adapter to read an inbound purchase order request from a file in a directory. See Oracle BPEL Process Manager Order Booking Tutorial for a tutorial that uses the file reading functionality of the file adapter.

Message Debatching

This demonstration shows how the file adapter processes native data containing multiple messages defined in a custom format. The file adapter takes a single inbound file of two records and outputs each record to its own file. For a demonstration of message debatching, go to

Oracle_Home\integration\orabpel\samples\tutorials\121.FileAdapter\Debatching

Reading Delimited Content Files

This demonstration shows how the file adapter reads CSV-formatted entries in an address book, transforms the file contents using XSLT, and stores the data in a fixed-length formatted file. For a demonstration of delimited content files, go to

Oracle_Home\integration\orabpel\samples\tutorials\121.FileAdapter\FlatStructure

Reading Positional (Fixed Length) Content Files

This demonstration shows how the file adapter reads CSV-formatted entries in an address book, transforms the file contents using XSLT, and stores the data in a fixed-length formatted file. For a positional (fixed length) demonstration, go to

Oracle_Home\integration\orabpel\samples\tutorials\121.FileAdapter\FlatStructure

File Writing

A simple file writing demonstration is provided as part of the larger tutorial described in "File Reading". In the file writing portion, you configure the file adapter to write an outbound purchase order acknowledgment to a file in a directory.

See Oracle BPEL Process Manager Order Booking Tutorial for a demonstration that uses the file writing functionality of the file adapter.

FTP Adapter Use Case

This demonstration shows how the file adapter processes native data containing multiple messages defined in a custom format. The native data instance contains an invoice and purchase order.

In the inbound direction, the FTP adapter retrieves a remote file, processes the file, and publishes the invoice and purchase order separately to the debatching BPEL process.

In the outbound direction, only purchase orders are generated. The debatching BPEL process transforms an invoice to a purchase order. The purchase record is simply copied over. All purchase orders are then written in separate remote output files. For an FTP demonstration, go to

Oracle_Home\integration\orabpel\samples\tutorials\129.FTPAdapter\FTPDebatching

Summary

This chapter describes how you use the file and FTP adapters so that your BPEL process can exchange (read and write) files (both XML and non-XML) on local file systems and remote file systems (through FTP).