Testing the Interaction Configurations
The FileReader component reads files from the file system and sends their contents to the output port. The source file can either be text or binary.
Text file
Text file may be read from a specified file in an unstructured fashion and the content is sent in a single message.
Binary file
Binary file contents are read as bytes of data from the source file and are sent in chunks or bundles to the output port of the FileReader component based on the configuration properties of this component.
Points to note
The component runs on the peer server and therefore the file paths and directories mentioned in the CPS should be valid on the machine where the peer server is running. If the component fails over to another peer server, ensure that the machine on which the secondary peer server is running must have the same path available.
The unstructured plain text can be transformed into its corresponding XML using the Text2XML component.
Number of outgoing messages for an input binary file = ceil (Size of File/ Chunk Size).
Business logic configuration details are configured in the Interaction
Configurations panel. Figure 1 below illustrates the panel with
expert properties
view enabled.

Figure 1: Interaction Configurations
Is file Binary?
The property is used to specify if the input file which is being read is binary or a flat file.
Yes
The contents of the input binary file are read as binary data and are sent to the output port in chunks whose size, in bytes, is specified through the property Chunk size.
No
The contents of the target file are read in an unstructured fashion and the content is sent to the output port as a single message.
Chunk size (bytes)
When the input file being read is binary, user can choose to receive the contents read from the file in chunks of binary data at the output ports. The size of these chunks (in bytes) can be specified in this property. When the chunk size is specified as 0 bytes, the whole file is read in a single run.
Note: This property is visible only when property Is file Binary? is set to Yes.
The number of output messages received = ceil (Size of File / Chunk size). The last output message received can be identified by the value of the property COMPLETE in its message headers. Refer Table 1 for information on message headers.
Is configured for different machine?
Specifies whether the Peer Server on which the component is to be launched and Fiorano Studio are running on the same machine or on different machines. This helps the component to determine the type of dialog to be shown while providing the paths of Source Directory, Working Directory and Error Directory. When both the Peer Server and the Studio are running on the same machine, the paths to the above specified directories can be chosen from a file dialog with the directory structure of the current machine. Otherwise, a text editor will be shown where the paths of Source/Working/Error directories need to be specified.
Yes
If the Peer Server on which the component is to be launched and Fiorano Studio are running on different machines.
No
If Peer Server and Fiorano Studio are running on the same machine.
Note: If Yes is specified, a text editor is shown to set the path of file and if No is specified, a file dialog is shown with directory structure to set the file path as shown in Figures 2 and 3 respectively.

Figure 2: Specifying directory path using Text Editor

Figure 3: Choosing directory path using File Dialog
Compute Paths relative to Directory
The path of the directory relative to which the paths of Source Directory, Working Directory, Error Directory and Postprocessing Directory are calculated. By default, this points to the FIORANO_HOME directory. If the paths specified for Source/Working/Error/Postprocessing directories are not absolute, their paths are calculated relative to the directory specified here.
Note: If the path specified for Source Directory/Working Directory/Error Directory/Postprocessing directory is absolute, the path specified for Compute Paths relative to directory will not be used in the computation of the path for that particular directory.
File name
The name of the file to be read. A pattern of file names can also be provided using wild character *. Multiple patterns are not allowed. All the files in the Source Directory are checked against this pattern and are suitably processed.
Example: *.txt includes all the files with a .txt extension.
S*.* would include Sample.txt, Service.doc, but not SampleFile
Note:
Only a single pattern of names can be specified. Multiple formats are not supported while specifying the File name
When the component is not in scheduling mode, the file name can be specified in the input message to the component and the name specified in the input message overrides the file name (if any) provided during the configuration.
When a pattern of file names is specified, there is no guarantee that the matching files will be processed in any specific order.
Source Directory
The directory which holds the file(s) to be read has to be specified in Source Directory. All the files in this directory whose names match the pattern specified for the File name property will be processed. The files present in the sub-directories are not considered.
An absolute path or a path relative to the directory specified in the Compute Paths relative to Directory can be provided.
If Is configured on different machine?
is set to No, clicking the ellipses
button
opens a file dialog as shown in Figure 3, where
the directory can be chosen from the file system. Otherwise a text editor
pops up where the path of the directory needs to be specified as shown
in Figure 2.
The path provided here should point to an existing directory.
Note:
The directory specified in Compute Paths relative to Directory property will be used in computing the path only if the path specified here is not absolute.
The FileReader throws an exception if the specified directory does not exist.
If the component is not configured in scheduling mode, the Source Directory can be specified in the input message to the component and the directory specified during configuration, if any, is overridden by the one provided in the input message.
File Encoding

Figure 4: Different type of File Encoding
The encoding to be used while reading the file. Figure 4 shows all the encodings that can be used.
ASCII
A coding standard used to represent plain text. It is based on English Alphabetical order.
Cp1252
This is a character encoding of the Latin alphabet
UTF8
A variable-length character encoding for Unicode
UTF-16
This too is a variable-length character encoding for Unicode. The encoding form maps each character to a sequence of 16-bit words
ISO8859_1
ISO 8859-1, more formally cited as ISO/IEC 8859-1 is part 1 of ISO/IEC 8859, a standard character encoding of the Latin alphabet
EUC_KR
EUC_JP
EUC_CN
EUC_TW
EUC_KR, EUC_JP, EUC_CN, EUC_TW are multi-byte character encoding systems used for Korean, Japanese, Simplified Chinese, and Traditional Chinese languages respectively.
Note: Reading UTF files with a byte order mark (BOM) attached to the beginning of the file may not give the desired result.
PreProcessing Command
Script or Command that is to be executed before the processing on file
starts. A Command can be entered in the text area provided against this
property in the CPS. To provide a script file, the file dialog which is
shown by clicking the ellipses button
can be used.
By default, the component appends the absolute path of the file that is currently taken up for processing to this script / command, that is, the absolute path of the file would be the first argument to this script / command. More arguments for this command could be specified using the property PreProcessing Arguments.
The final command formed by the FileReader would be
<PreProcessing Command> + <Absolute path of the file taken up for processing> + <PreProcessing Arguments>.
PreProcessing Arguments
Arguments that are passed to preprocessing script or command. As mentioned in the PreProcessing Command section, the component, by default, appends the absolute path of the file that is currently taken up for processing to the PreProcessing Command. Any other arguments that need to be passed to the PreProcessing Command can be provided here.
The use of PreProcessing Commands and Arguments is explained in this Sample Scenario
Sample scenario:
Copying all the files present in Error directory to a backup location before the processing on a file starts.
Solution:
A batch file copyerrors.bat with content copy C:\FileReader\ErrorDir %2 is written and is placed in C:\. The path of this batch file is specified for PreProcessing Command. The backup location (C:\ProcessingFailures) is specified as the value for PreProcessing Arguments.
Let C:\test.txt be the file picked up for processing. With this configuration, the command formed by FileReader would be C:\copyerrors.bat C:\test.txt C:\ProcessingFailures. The copy command executed finally would be copy C:\FileReader\ErrorDir C:\ProcessingFailures which will move all the files present in C:\FileReader\ErrorDir to the backup location C:\ProcessingFailures.
Use Working Directory
Specify if the working directory is to used.
Yes
The files will be moved from the Source Directory to Working directory while FileReader processes the file. The component needs write/modify permissions on the Source Directory to be able to use a working directory. If such permissions are not available, set this property to No.
No
Files will not be moved to the Working directory.
Note: The property Working Directory becomes visible only when Use Working Directory is set to Yes.
Working Directory
The path of the directory which is to be used for intermediate processing
of files. If preprocessing actions are specified, the working directory
will be used while processing them. If Is configured
on different machine? is set to No,
clicking the ellipses button
will open a file dialog
as shown in Figure 3, where the directory can be chosen from the file
system. Otherwise a text editor pops up where the path of the directory
needs to be specified as shown in Figure 2.
Note:
This property is visible only when Use Working Directory is set to Yes.
Either an absolute path or a path relative to the directory specified in the Compute Paths relative to Directory can be provided.
If this directory does not exist, FileReader creates it while processing the input message.
FileReader requires write permissions on Working and Error Directories
Error Directory
Path of the directory which should hold the files whose processing has not been successful.
If Is configured on different machine?
is set to No, clicking the ellipses button
will open a file dialog as shown in Figure 3, where
the directory can be chosen from the file system. Otherwise a text editor
pops up where the path of the directory needs to be specified as shown
in Figure 2.
Note:
Either an absolute path or a path relative to the directory specified in the Compute Paths relative to Directory can be provided.
If this directory does not exist, FileReader creates it while processing the input message.
FileReader requires write permissions on Working and Error Directories.
Postprocessing Action
Action to be taken on the file after it is read successfully. Figure 5 shows all the Postprocessing Actions that are allowed.

Figure 5: Postprocessing Actions
DELETE
Delete the file after reading it successfully.
MOVE
Move the file to a different location (specified by the property Postprocessing Directory)
Note: When MOVE is selected as the Postprocessing Action, four other properties become visible (Shown in the Figure 6)

Figure 6: MOVE action
NO_ACTION
Take no action on the file.
Postprocessing Directory
The directory to which files are to be moved when they are read successfully, when MOVE is selected as the Postprocessing Action.
If Is configured on different machine?
is set to No, clicking the ellipses(
) button will open a file dialog, as shown in Figure 3, where
the directory can be chosen from the file system. Otherwise a text editor
pops up where the path of the directory needs to be typed in as shown
in Figure 2.
Note: This option is visible only when MOVE is selected as the Postprocessing Action.
Append timestamp?
Specifies if a time stamp has to be appended to the file names after they have been moved to the Postprocessing Directory.
Yes
FileReader adds a time stamp whose format is provided through the Timestamp format property and a counter (if Append counter? is set to Yes).
No
No timestamp is added to the files that have been moved to the Postprocessing directory.
Note: This option is visible only when MOVE is selected as the Postprocessing Action.
Timestamp format
The format of the time stamp to be appended to the file name can be specified here. The descriptions of the symbols that can be used in the time stamp formats are depicted in Figure 7.

Figure 7: Symbols used in Timestamp format
Example: ddMMyyyy_HHmm
Note:
This property is visible ONLY when the Append timestamp is set to Yes.
Avoid using slashes ('/' or '\') in the time stamp format as they can be mis-interpreted as File Separators and can lead to confusion.
Special characters that are not allowed in file names should not be included in the timestamp format (This can be platform specific).
Append counter?
Yes
A counter is appended to the file name of each processed file in addition to the time stamp. Appending counter to file names ensures that no two files in the Postprocessing directory will have same name. The name of the file would look like <filename>_<time stamp>_<counter>.
No
No counter is added to the files that have been moved to the Postprocessing directory.
Note: This property is visible ONLY when the Append timestamp is set to Yes.
Validate Input
If set to Yes, the input request sent to the FileReader is validated against the input port XSD of the component.
Process Pending files in Working Directory
Specify if the pending files present in the Working directory are to be processed. When this property is enabled, for every input request to read a file from a specific directory, the file is searched in Working directory in addition to the specified directory. If the component is in scheduling mode, enabling this property processes the files in the Working directory as well.
Note:
If a file with same name exists in both the Source directory and Working directory, the file in the Source directory is processed.
Setting this property to Yes will not have any effect if Use Working Directory is NO.
Output XSD
This property is used to set the schema of the output message. If the file content is expected to be an XML, setting its schema on the output port using the Output XSD can be useful for applying transformations on the output message. The XSD can be provided using the Schema Editor as shown in the Figure 8.

Figure 8: Schema editor to provide Output XSD
Header properties
Table 1 shows the descriptions of header properties set by the component on the output message when Flat/Binary files are processed.
|
Type of the file processed |
Header property |
Description |
|
Flat/Binary |
FileName |
Name of the file being read. |
|
FilePath |
Path of the directory which holds the source file. | |
|
Size |
The size of the file being read. | |
|
START_EVENT |
An output message with this property set to true determines that the message is the first record in the set of responses generated for an input message. Note: This property appears only on the first record in the set of responses. | |
|
CLOSE_EVENT |
An output message with this property set to true determines that the message is the last record in the set of responses generated for an input message. Note: This property appears only on the last record in the set of responses. | |
|
RECORD_INDEX |
A value n for this property indicates that this is the nth response generated for an input message. | |
|
Flat |
FullName |
Absolute path of the processed file. |
|
ReadAccess |
Determines if the processed file is readable. | |
|
WriteAccess |
Determines if the processed file is writable. | |
|
Type |
File / Directory. | |
|
Binary |
NEW |
An output message with this property set to true determines that this is the first chunk of the binary file being read. |
|
COMPLETE |
An output message with this property set to true determines that this is the last chunk of the binary file being read. | |
|
START_INDEX |
Determines the offset of first byte of the current chunk read. | |
|
END_INDEX |
Determines the offset of last byte of the current chunk read. |
When FileReader is not in scheduling mode, messages can be sent onto the input port of the component specifying the file to be read and the location of the file. The schema of the input XML message is shown in Figure 10.

Figure 9: Schema of the input message
FileName is the name of the file which is to be read.
Directory is the location of the file.
Note: If the values for FileName and Directory are not specified in the input message, the values configured for the CPS properties File Name and Source Directory are used.
The output schema depends on the configuration of property Output XSD. Schema provided for this property is directly set as schema on output port. For more information, please refer to Output XSD in Interaction Configuration section.
Interaction configurations can be tested from the CPS by clicking the Test button. Figure 10 and Figure 11 show the sample input and the corresponding output respectively.

Figure 10: Sample input

Figure 11: Output produced for sample input shown in Figure 10
Reading simple text files and displaying the contents.
Configure the FileReader as described in Configuration and Testing section and use feeder and display component to send sample input and check the response respectively.

Figure 12: Demonstrating scenario 1 with sample input and output
Input Message:
<ns1:Input xmlns:ns1="http://www.fiorano.com/fesb/activity/FileReader1">
<FileName>Input.txt</FileName>
<Directory>C:\Read</Directory>
</ns1:Input>
Output Message:
This is a sample file (Contents of the input file).
In a revenue control packet scenario transaction files are read and then transformed.

Figure 13: Revenue Control Packet Scenario
The event process demonstrating this scenario is bundled with the installer.
Documentation of the scenario and instructions to run the flow can be found in the Help tab of flow when open in Studio.
Best Practices to read a file from a network drive using the FileReader component:
To access a file present in a network drive, FileReader component needs full permissions on that directory. Please enable the option "Allow Network Users to change my files" while sharing a directory.
If you do not have permissions to change the files, then in the File Reader Custom Property Sheet you need to set "Use Working Directory" to "No".
In case running peer server as Windows/Linux service, it is possible that the network drive is not mounted by the time the peer server has started the file components. In such a case, making the peer service dependent on the service that is mounting the Network Drive will help.
Copyright © 1999-2008, Fiorano Software Technologies Pvt. Ltd. All rights reserved.
Copyright © 2008-2009, Fiorano Software Pty. Ltd. All rights reserved.
This software is the confidential and proprietary information of Fiorano Software ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the license agreement enclosed with this product or entered into with Fiorano.