The input message provides the attachment file.
Only the job's result is expected in the response.
h1. Creating and exporting the job
The job to be executed performs the following actions:
# The job is passed the file whose content must be inserted. The file is passed as an attachment to the message.
# The job loads the file's content.
# The job connects to a database and writes the data in this database.
This job has one context variable, pointing to the location of the file whose content must be loaded.
\\
{info}
In the scope of this use case, it is assumed there is a database *formationtalend* on the localhost, having a table named *customers*.
The schema of the *customers* table includes two columns named *CustomerName* and *CustomerAddress*, both being of type varchar(255).
{info}
h2. Creating the job
h2. Exporting the job
Select the job and right-click it. Select *Export to Petals ESB*.
Update the target destination.
Let the job be exposed as a singleton.
Click *Edit the exposed contexts*.
A dialog shows up. Export the _outputLocation_ context as an *Out-Attachment*.
You should have the following dialog:
Click the *Export mode* column, and select *Parameter* in the combo box. Click *OK*.
The link label should be updated and indicate the number of exported contexts.
Click *Finish*.
h1. Deploying and testing in Petals
h2. Looking at the generated WSDL
In the created Petals service assembly, the most interesting thing to look at is the WSDL.
Indeed, the WSDL will determine the way the exported service will be called.
\\
The input message's description requires empty parameters.
{code:lang=xml}
{code}
\\
And the output message includes the job's result and the output attachment.
{code:lang=xml}
{code}
h2. Deploying and testing this new service
Since we use attachments, we will prefer using a Java client instead of SoapUI.
However, it is possible to use SoapUI to send or receive messages with attachments. Just make sure the MTOM property is activated.
The first thing to do is to create a service-unit for the Petals-BC-SOAP component, that exposes (consumes) our _Talend job as a service_ outside the bus.
This step is not described here. You can take a look at the Petals-BC-SOAP documentation and the Petals Studio documentation.
Just make sure the SOAP configuration uses the InOut MEP.
Then, to generate a client from the WSDL, you can use Apache CXF or Axis2.
In the scope of this use case, Apache CXF is used. Only the client class is shown here.