Topics
Service-Oriented Architecture
SOA Suite Essentials for WLI Users
Comparison: WLI File Control and the Oracle File Adapterby Daniel Amadei and Heidi Buelow This installment of the SOA Suite Essentials for WLI Users series maps WebLogic Integration's file control capabilities to their equivalents in Oracle BPEL Process Manager.Published May 2009
[ Page 1] [ Page 2] [ Page 3] [ Page 4] Receiving an XML, transforming to CSV and writing to a file using FTP in BPELIn this last use case, we'll read a file and then write the data in a comma separated value (csv) format. This time, we will show you how to poll for the file in the directory (if you prefer, instead you can use the same method to read a file as in the first use case to align more closely with the third WLI use case). We start the process by polling for the file and letting the read service initiate the BPEL process. We then write the file using the FTP adapter while also formatting the data in the csv format. You must have an FTP Server configured to use with this project. To setup a local FTP, get the ftpserver-1.0.0-M3.zip file from the sample files folder and unzip into /tmp. Next, make sure you have the JAVA_HOME environment variable set to your local installation of the Java JDK. To start the FTP server from a command prompt in Windows or shell in Unix, go to the /tmp/ftpserver-1.0.0-M3/bin directory and run the following command
ftpd.bat res/conf/ftpd-typical.xml
ftpd.sh res/conf/ftpd-typical.xml The SOA Suite server is already configured to use an FTP client to access an FTP server. Let's update that configuration for our new FTP server. The steps are similar whether you are using OC4J or WebLogic server to update the connection factory.
Now let's create the new BPEL project. In JDeveloper, right-click on your application and select New Project. Select BPEL Process Project under General/Projects for the project type. Enter TransformXmlToRawDataAndWriteToFTP for the process name. Select Empty BPEL Process for the template type. Select Finish. The project is created. Drag a Receive activity to the Drop Activity Here box. The activity is highlighted in yellow when it is in the right place. Wire the receive activity to the readPartnerSchema partnerlink by dragging the left arrow to the partnerlink. The receive properties dialog opens. The partnerlink and operation are filled in automatically. Enter Receive_Stocks for the name and select the Auto-Create Variable button. In the Create Variable dialog change the variable name to stocksXML, select OK. In the Receive dialog, check the Create Instance checkbox, select OK. Now create the service for writing the csv file. We are going to write the file using FTP. Drag an FTP adapter to the Services pane on the right side of the BPEL design screen. The wizard opens. Select Next to go to step 1. Enter FTPFileControl for the service name and select Next. On this page of the wizard you set the FTP JNDI name. This is the FTP configured in your SOA Suite server administration. Accept the default value of eis/FTP/FTPAdapter to use the FTP setup you edited earlier. Select ASCII for the file type and Put for the operation type and select Next. Enter the directory to which you will write the file. In this case, it must be a directory within the FTP server structure. Enter a forwared slash ( /) to write the file to the default location for the sample FTP Server provided. For the File Naming Convention, enter partnerStocks%SEQ%.csv_. Leave the remaining values as defaulted and select Next. Use the Browse button to open the sample stocks.csv file provided in your sample files directory. You'll see the text in the window. Select Next. Select File contains multiple record instances and select Next. Enter the namespace as desired and enter Stocks as the element name for multiple records and Stock for the single record element name and select Next. Select Next three more times to accept the defaults for the format specification and then select Finish. Back in the adapter wizard you see the newly created xsd that defines your string data. Select Next and then select Finish. Select OK on the partner link dialog. Let's invoke our write service and create the variable needed with the correct message type. Then we'll transform the input data to the output data, and we are done. Drag an Invoke directly below the Receive. Wire it to the FTPFileControl partnerlink and the Invoke dialog opens. Name the Invoke Invoke_FTPFileControl and select the Automatically Create Input Variable button to the right of the Input Variable box. Change the variable name to stocksCSV. Select OK. Select OK to set the invoke properties. Now we need to transform the data read from the file into the format required for input to the FTP service. Drag a Transform activity and drop it between the Receive and Invoke activities. Set the source to stocksXML and the target to stocksCSV. Enter the transform file name and select Create This time, the field names are different and you must manually wire each field. After wiring the three fields, wire Stocks to Stocks and the for-each XSLT construct is created for you, or add it manually so the result is as shown in the image below. Select Save All. You are finished implementing this use case. Once you have confirmed that your FTP server is running you can deploy. This process polls for the file and just waits for the file to show up. The output file from the previous use case, partnerStocks_1.xml, is the input file for this one, or you can use the partnerStocks.xml provided in your samples directory. Move or copy the file to the input directory for this process. Watch for the file to disappear and then check the FTP default output directory, \tmp\ftpserver-1.0.0-M3\res\home, for the new output file. View the contents of that file. You can also view the audit trail in the BPEL Console. This use case shows how to change the data in a file from one format to another. You can extend your BPEL process to operate on the data in other ways as desired. You have completed three use cases that show you various features of the file adapter functionality. As you can see, this functionality is quite simple to create using point/click declarative editing. You can read and write a file in various formats and transform the data within the BPEL process as desired. Key Takeaways and RecommendationsThis article focused on synchronous file manipulation and data transformation in WLI and BPEL PM. The table below states what was demonstrated during the article, highlighting how each feature is achieved in WLI and BPEL PM respectively. Both products provide the needed functionality.
Experienced WLI users will find that all of the functionality they use in WLI for file handling is available in Oracle BPEL PM. Oracle BPEL Process Manager's design time provides a point-and-click declarative style user interface allowing quick ramp up for new users bringing them to the Oracle SOA Suite world quickly and easily.
|
||||||||||||||||||||||||||||||||||