To configure a JBI component to access web services, you specify both service level WSDL elements and binding level WSDL elements.
Service level WSDL elements allow you to specify the “connectivity” information to a file system. The File address extensibility element is the File Binding Component service level WSDL element.
The service element specifies the connectivity to the file system using the File address element file:address. The properties of address further allows you to specify a path to a directory and then to specify whether the path is a absolute path or a relative path.
When you create a WSDL file for a BPEL project in the NetBeans IDE, the new WSDL Document wizard generates the address service definition. You can then edit the properties of address service to specify the path.
The following table describes the properties available for this service:
The following example illustrates the WSDL service element:
Binding level WSDL elements allow you to define the file “transport” specific information for operations and messages. The File Binding Component binding level WSDL elements include the File binding, operation, and message extensibility elements.
The file binding extensibility element allows the association of a binding to be file protocol specific. The message format and protocol for the File Binding Component is always a file that is supported on the native file system. When you create a WSDL file for a BPEL project in the NetBeans IDE, the New WSDL Document wizard generates the file binding definition, which includes a name you specify and a type that is generated by the wizard.
The following example illustrates the File binding element:
The file operation element defines the supported operations. For the File Binding Component the operations that can be supported are one-way and request-response.
The following example illustrates the File operation element:
The File message element extends the binding element to specify properties associated with reading input files or writing output files in the file system. In the NetBeans IDE, select the properties for a file:messages() element to specify the behavior for the message.
The following table describes the message properties available for reading from or writing to the file system.
Table 1 Message Properties to Read/Write to a File System
Property |
Description |
Required |
Example |
---|---|---|---|
Use |
Specifies whether a message (or message part) is literal or encoded. If encoded is specified, then you must also specify the encoder using the encodingStyle() property. |
Required |
Literal (Default) |
fileName |
Defines the file name relative to the specified directory to read from or write to. If fileNameIsPattern() is false, this attribute specifies an actual file name. Otherwise, this attribute specifies a pattern marker used for filtering input files from the directory, or a file name format to write to the directory. |
Required |
data.xml (Default) |
fileNameIsPattern |
Indicates whether or not the fileName() attribute designates a filename pattern. |
Optional |
false |
recordDelimiter |
Defines the record delimiter when multiple records are present. The value of this attribute is considered only if multipleRecordsPerFile() is true. If no value is specified for this attribute but maxBytesPerRecord() is defined when reading a file, it is assumed that each record is of fixed length with the length being the value defined for maxBytesPerRecord(). Otherwise, the default record delimiter is the linefeed character. |
Optional |
\r\n |
pollingInterval |
Defines the polling interval that the File Binding Component searches for input files in the specified directory. The polling interval is specified in milliseconds and has a default value of 1000ms. This attribute has no effect for writing. |
Required |
1000 (Default) |
fileType |
Specifies whether the file is a text file or binary file. |
Optional |
text (Default) |
encodingStyle |
Specifies the encoding type associated with the message (or message part). This also defines the encoder type responsible to process the encoded data. |
Optional |
customencoder-1.0 |
part |
The abstract WSDL configuration for message can have one or more parts. The part() property references one of the parts that is named in the abstract WSDL configuration. |
Optional |
Part1 |
addEOL |
Defines whether newline characters (EOL characters) should be appended to the outbound message or to each record incase of multiple records.. This attribute has no effect for reading |
Optional |
false |
removeEOL |
Defines whether newline characters (EOL characters) should be removed before processing. or be removed for each record incase of multiple records. This attribute has no effect for writing |
Optional |
false |
maxBytesPerRecord |
Defines the maximum number of bytes to be read per record. If only a single record is present, this attribute defines the total number of bytes to be read. This attribute has no effect for writing. |
Optional |
1024 |
multipleRecordsPerFile |
Specifies whether the file to read from or write to contains multiple records or should be considered a single payload. |
Optional |
false |
archive |
Specifies whether a message is archived after it is read for processing by the File Binding Component. When true, the message is moved to the directory specified by archiveDirectory. When a file is processed, the File Binding Component renames the file to input_file_name_processed() or input_file_name_error(), depending on the success of the operation. If the archive() property is true, the file is then moved to the archiveDirectory and a UUID is appended to the file name. |
Optional |
true |
archiveDirectory |
If the archive() property is set to true(), archiveDirectory() specifies the directory to which processed (read) messages will be moved. Filenames for archived messages are tagged with a UUID to avoid file name collision in the archive directory. If the archiveDirIsRelative() property is true(), then the directory specified here is a relative directory. The parent directory is the directory specified in the fileDirectory() property for the file:address() element. |
Optional |
true |
archiveDirIsRelative |
Indicates whether the directory specified in archiveDirectory() is an absolute directory or a relative directory. If true(), the parent directory is the directory specified in the fileDirectory() property for the file:address() element. |
Optional |
true |
protect |
Indicates if overwrite protection is required before writing messages to a file. When true(), existing files of the same name will be moved to the directory specified by protectDirectory before the current message is written. When false(), the files of the same name will be overwritten. |
Optional |
true |
protectDirectory |
If the protect property is set to true, protectDirectory specifies the directory to which files will be moved to prevent them from being overwritten. Filenames for protected messages are tagged with a UUID to avoid file name collision in the protect directory. If the protectDirIsRelative() property is true(), then the directory specified here is a relative directory. The parent directory is the directory specified in the fileDirectory() property for the file:address() element. |
Optional |
false |
protectDirIsRelative |
Indicates whether the directory specified in protectDirectory() is an absolute directory or a relative directory. If true(), then the parent directory is the directory specified in the fileDirectory() property for the file:address() element. |
Optional |
true |
stage |
Indicates if staging is enabled. If set to true(), then messages are first written to the directory specified by stagingDirectory. When the message is completely written to the staging directory, then it is moved to the target directory for the message. Filenames for staged messages are tagged with a UUID to avoid file name collision in the staging directory. |
Optional |
false |
stageDirectory |
If the stage property is set to true, stageDirectory() specifies the directory to which files will first be written before being moved to the target directory for the message. If the stageDirIsRelative() property is true, then the directory specified here is a relative directory. The parent directory is the directory specified in the fileDirectory() property for the file:address() element. |
Optional |
false |
stageDirIsRelative |
Indicates whether the directory specified in stageDirectory is an absolute directory or a relative directory. If true, then the parent directory is the directory specified in the fileDirectory() property for the file:address() element. |
Optional |
true |
File name patterns are used as a name filter for inbound message processing and as a name generator for outbound message processing. The multiple processing threads that make up the runtime File Binding Component fall into two types:
Inbound Processors: Message consumers that poll an input directory at a specified interval for a specific file name.
Outbound Processors: Message provisioners that write messages to an output directory by a specific file name.
Literal File Name
Input and output file names can be literal, or use a pattern.
Input: If the input file name is a literal, the inbound processor polls the input directory for a file by that name, and the content of the file is converted to a normalized message.
Output: If the output file name is a literal, the outbound processor writes the denormalized message to a file by that name.
Pattern File Name
In most cases, the file names specified for inbound or outbound processing are patterns. File name pattern is a proprietary mechanism of the File Binding Component.
Inbound: When used by the inbound processor, the pattern serves as a filter. That is, if a file name matches the pattern, it is selected by the inbound processor and its content is read, normalized, and sent.
Outbound: When used by the outbound processor, the pattern serves as concrete name generator. That is, the special pattern symbols, such as %d(), %u(), %t(), and %{seq_name}(), that appear in the file name pattern specified as output file, will be expanded. The symbols are substituted with their current value and derive a concrete file name, to which the denormalized message is written.
When you set fileNameIsPattern() on a message property, you can specify patterns for generating filenames for outbound messages or for reading filenames for inbound messages.
You can use application variables together with file name patterns to specify paths.
The following example shows how to use an application variable when specifying a path name to a file that uses the %d pattern marker:
This example specifies a directory defined by the application variable base_dir. The application variable is defined as a File Binding component runtime property. If base_dir is defined as /duke/home, then this example reads or writes the following files: