|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Changes (22)
View Page History{section}
{column}
{column}
h1. Preliminary notes
h2. Exporting the job
Select the job and right-click it. Select *Export to Petals ESB*. Job Scripts*.
Update the target destination.
In the *Export type* combo, select *Petals ESB*.
Let Update the target destination and let the job be exposed as a singleton.
Click *Edit the exposed contexts*.
A dialog shows up. Click the *Export mode* column, and select *Parameter* in the combo box. Click *OK*.
You should have the following dialog:
!PetalsToJob_file_export.jpg! !InAtt.jpg!
The link label should be updated and indicate the number of exported contexts.
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.
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.
As an example, the following code was generated with Apache CXF 2.2.6.
Check the CXF documentation to see how to develop a service consumer in Java.
Check the CXF documentation to see how to develop a service consumer in Java.
Only the main client class is shown here.
\\
The client's code is the following:
{code:lang=java}
{code:lang=java}
package org.ow2.petals.talend;
TODO
/**
* Please modify this class to meet your needs This class is not complete
*/
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.soap.SOAPBinding;
import net.java.dev.jaxb.array.StringArray;
/**
* This class was generated by Apache CXF 2.2.6 Mon Mar 29 18:38:51 CEST 2010
* Generated source version: 2.2.6
*/
public final class CsvToXmlServicePortType_CsvToXmlEndpoint_Client {
private static final QName SERVICE_NAME = new QName(
"http://petals.ow2.org/talend/", "CsvToXmlService" );
/**
* Constructor.
*/
private CsvToXmlServicePortType_CsvToXmlEndpoint_Client() {
// nothing
}
/**
* Main method.
* @param args
* @throws Exception
*/
public static void main( String args[] ) throws Exception {
URL wsdlURL = CsvToXmlService.WSDL_LOCATION;
if( args.length > 0 ) {
File wsdlFile = new File( args[ 0 ]);
try {
if( wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
}
else {
wsdlURL = new URL( args[ 0 ]);
}
} catch( MalformedURLException e ) {
e.printStackTrace();
}
}
CsvToXmlService ss = new CsvToXmlService( wsdlURL, SERVICE_NAME );
CsvToXmlServicePortType port = ss.getCsvToXmlEndpoint();
// Activate the MTOM mode
((SOAPBinding) ((BindingProvider) port).getBinding()).setMTOMEnabled( true );
//
// Set the input attachment
File f = new File( "C:/Documents and Settings/vzurczak/Bureau/in.csv" );
DataHandler dh = new DataHandler( new FileDataSource( f ));
Attachment att = new Attachment();
att.setFileContent( dh );
InAttachments ia = new InAttachments();
ia.setOutputLocation( att );
//
{
System.out.println( "Invoking executeJob..." );
org.ow2.petals.talend.TalendContexts contexts = null;
org.ow2.petals.talend.InAttachments inAttachments = null;
java.util.List<org.ow2.petals.talend.InRow> inDataBean = null;
java.util.List<java.lang.String> talendOption = null;
try {
org.ow2.petals.talend.TalendJobOutput result = port
.executeJob( contexts,
inAttachments,
inDataBean,
talendOption );
if( result == null )
System.out.println( "Something went wrong, the result is null." );
else {
// The job's result
System.out.println( "Job's result = " );
int cpt = 0;
for( StringArray row : result.getExecutionResult()) {
System.out.print( "Row " + cpt++ + ": " );
for( String col : row.getItem())
System.out.print( col + " ; " );
}
}
} catch( TalendTechnicalException_Exception e ) {
System.out.println( "Expected exception: TalendTechnicalException has occurred." );
System.out.println( e.toString());
} catch( TalendBusinessException_Exception e ) {
System.out.println( "Expected exception: TalendBusinessException has occurred." );
System.out.println( e.toString());
}
}
System.exit( 0 );
}
}
* Please modify this class to meet your needs This class is not complete
*/
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.soap.SOAPBinding;
import net.java.dev.jaxb.array.StringArray;
/**
* This class was generated by Apache CXF 2.2.6 Mon Mar 29 18:38:51 CEST 2010
* Generated source version: 2.2.6
*/
public final class CsvToXmlServicePortType_CsvToXmlEndpoint_Client {
private static final QName SERVICE_NAME = new QName(
"http://petals.ow2.org/talend/", "CsvToXmlService" );
/**
* Constructor.
*/
private CsvToXmlServicePortType_CsvToXmlEndpoint_Client() {
// nothing
}
/**
* Main method.
* @param args
* @throws Exception
*/
public static void main( String args[] ) throws Exception {
URL wsdlURL = CsvToXmlService.WSDL_LOCATION;
if( args.length > 0 ) {
File wsdlFile = new File( args[ 0 ]);
try {
if( wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
}
else {
wsdlURL = new URL( args[ 0 ]);
}
} catch( MalformedURLException e ) {
e.printStackTrace();
}
}
CsvToXmlService ss = new CsvToXmlService( wsdlURL, SERVICE_NAME );
CsvToXmlServicePortType port = ss.getCsvToXmlEndpoint();
// Activate the MTOM mode
((SOAPBinding) ((BindingProvider) port).getBinding()).setMTOMEnabled( true );
//
// Set the input attachment
File f = new File( "C:/Documents and Settings/vzurczak/Bureau/in.csv" );
DataHandler dh = new DataHandler( new FileDataSource( f ));
Attachment att = new Attachment();
att.setFileContent( dh );
InAttachments ia = new InAttachments();
ia.setOutputLocation( att );
//
{
System.out.println( "Invoking executeJob..." );
org.ow2.petals.talend.TalendContexts contexts = null;
org.ow2.petals.talend.InAttachments inAttachments = null;
java.util.List<org.ow2.petals.talend.InRow> inDataBean = null;
java.util.List<java.lang.String> talendOption = null;
try {
org.ow2.petals.talend.TalendJobOutput result = port
.executeJob( contexts,
inAttachments,
inDataBean,
talendOption );
if( result == null )
System.out.println( "Something went wrong, the result is null." );
else {
// The job's result
System.out.println( "Job's result = " );
int cpt = 0;
for( StringArray row : result.getExecutionResult()) {
System.out.print( "Row " + cpt++ + ": " );
for( String col : row.getItem())
System.out.print( col + " ; " );
}
}
} catch( TalendTechnicalException_Exception e ) {
System.out.println( "Expected exception: TalendTechnicalException has occurred." );
System.out.println( e.toString());
} catch( TalendBusinessException_Exception e ) {
System.out.println( "Expected exception: TalendBusinessException has occurred." );
System.out.println( e.toString());
}
}
System.exit( 0 );
}
}
{code}
Notice that the MTOM-mode was activated. Not enabling it will result in errors.
\\
The execution output (displayed in the console) is:
{noformat}
todo
Invoking executeJob...
Job's result =
Row 0: 0 ;
Job's result =
Row 0: 0 ;
{noformat}
\\
If the job execution fails, the 0 is replaced by another integer, e.g. 1.
One failure reason can be, as an example, that the database is not started.
One failure reason can be, as an example, that the database is not started.
To determine the act cause of a problem, you would have to use logging features available in the Talend palet.
However, let's make it clear, the job's logs are managed independently of Petals and its monitoring capabilities.
However, let's make it clear, the job's logs are managed independently of Petals and its monitoring capabilities.
http://doc.petalslink.com/display/petalsesb/Data+Flow+-+From+Petals+to+a+Job+using+a+tPetalsInput
{column}
{column:width=350px}
{column:width=350px}