
If the received message is an XML content, the name of the created file would be either the configured file pattern (file-pattern), the operation of the message exchange, or the default name content.xml.
If the received message contains attachments, the name of the created files would be the names of the attachments.
For each file created, the system date is appended to this file name.
When deploying a service unit like in the previous code snippet, all the JBI messages received on the putService service will produce files in the $PETALS_HOME/filetransfer/out directory.
h2. Retrieve files from a folder : the GetFiles service
PROVIDE SERVICE : return files from a folder as XML message or attachements.
h3. Service Unit descriptor
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-4.0"
xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-2.2"
xmlns:generatedNs="http://petals.ow2.org/filetransfer">
<jbi:services binding-component="true">
<jbi:provides
interface-name="gefiletransfer:GetFiles"
service-name="generatedNs:myGetFilesService"
endpoint-name="getFilesServiceEndpoint">
<!-- WSDL file -->
<petalsCDK:wsdl xsi:nil="true" />
<!-- FileTransfer specific fields -->
<filetransfer:read-directory>${PETALS_HOME}/filetransfer</filetransfer:read-directory>
</jbi:provides>
</jbi:services>
</jbi:jbi>{code}
{include:0 CDK SU Provide Configuration}
Configuration of a Service Unit to provide the GetFiles services (FileTransfer)
|| Parameter || Description \\ || Description \\ || Required \\ ||
| read-directory | The directory where files will be searched when GetFiles is invoked. \\
Environment variables are supported with the form $\{myEnvVariable}. | \- | Yes |
| backup-directory | The directory where files are moved after being read. \\
Environment variables are supported with the form $\{myEnvVariable}. | The system default temporary directory \\
The system default temporary directory | Yes |
h3. Provider restrictions
The FileTransfer component supports only InOut or InOptionalOut message exchange pattern as service provider.
h3. Provider Usage
h4. GetFile operation
When the getFile operation is set on the incoming message exchange, the component returns the first file found in the configured directory, according to the file filter set in the XML request (the source of the IN message). The file is returned as an XML response message (OUT message), so the file MUST be an XML file \!
The IN message looks like :
{code:lang=xml}<q0:getFile xmlns:q0="http://petals.ow2.org/components/filetransfer/version-2.2">
<q0:filepattern>*.xml</q0:filepattern>
</q0:getFile>{code}
The OUT message returned to the consumer contains the XML content of the first file matching the pattern, in its source :
The read file is moved to the configured backup directory (backup-directory) or in the system default temporary directory.
{note}This operation is defined in the File Transfer abstract WSDL. You can import this abstract WSDL and define a concret WSDL to reference in your SU. Thus the service provided is properly defined by its WSDL.{note}
h4. GetFiles operation
When the getFiles operation is set on the incoming message exchange, the component returns all the files file found in
the configured directory (read-directory), according to the files filters set in the XML request. The files are all returned
as attachments. An XML report message is returned.
When the getFiles operation is set on the incoming message exchange, the component returns all the files file found in the configured directory (read-directory), according to the files filters set in the XML request. The files are all returned as attachments. An XML report message is returned.
The IN message looks like :
{code:lang=xml}<q0:getFiles xmlns:q0="http://petals.ow2.org/components/filetransfer/version-2.2">
<q0:filepattern>*.xml</q0:filepattern>
<q0:filepattern>picture.jpg</q0:filepattern>
<q0:filepattern>document??.doc</q0:filepattern>
</q0:getFiles>{code}
The OUT message returned to the consumer is defined as follow :
{code:lang=xml}<q0:getFilesResponse xmlns:q0="http://petals.ow2.org/components/filetransfer/version-2.2">
<q0:filename>file1.xml</q0:filename>
<q0:filename>file2.xml</q0:filename>
<q0:filename>picture.jpg</q0:filename>
<q0:filename>document_1.doc</q0:filename>
<q0:filename>document_2.doc</q0:filename>
</q0:getFilesResponse>{code}
Files are returned as attachments.
The read files are moved to the configured backup directory (backup-directory) or in the system default temporary directory.
{note}This operation is defined in the File Transfer abstract WSDL. You can import this abstract WSDL and define a concret WSDL to reference in your SU. Thus the service provided is properly defined by its WSDL.{note}
{column}
{column:width=350px}
{panel:title=Table of contents}{toc}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list}{panel}
{column}
{section}