Tags
Post this we use our FileAdapter to Rename or Move a File, this post will not be a result of the above and the part can be done.
See the links below to check the other parts of our project:
- Working with FileAdapter in BPEL – Part 1: Reading the file from directory
- Working with FileAdapter in BPEL – Part 2: Reading the file content
- Working with FileAdapter in BPEL – Part 3: Saving the file contents in the database
- Working with FileAdapter in BPEL – Part 4: Renaming or Moving a File
- Working with FileAdapter in BPEL – Part 5: Deleting a file
Let’s do a project for the part if you need it in the future just to engage in any specific project, so we will first create a project called FileAdapterUtilBPEL as follows:
Let us now import a WSDL which will set our operations and it contain our input (Request) and output (Response) responsible for our input and output parameters which we will use in our project BPEL
Then import the WSDL for our project FileAdapterUtilBPEL clicking here
Now copy this WSDL into SOA Content of your project
Creating the BPEL:
Drag a BPEL Process component, and check the options as follows:
- Choose BPEL 2.0 Specification
- Name it RenameOrMoveBPELProcess
- In Template select Base on a WSDL
- In Service Name put RenameOrMoveFile
- Let marked the flag Expose as a SOAP serivice
- In WSDL URL look for the WSDL that lowered: FileUtilContract.wsdl
Now drag a File Adapter into your composite.xml and name it RenameOrMoveFileAdapter
Leave checked the Define from operation and schema (specified later)
Below check the Write
Below you do not need much because we specify the data that we insert here will be lost later because we will change the properties of this component so we can put whatever we want in this step.
Then, put just one bar / in Directory for Outgoing Files and put a * in File Naming Convention and click in Next
Check the Native format translation is not required
Click Finish
Now connect your RenameOrMoveBPELProcess with her File Adapter and will be as follows:
In his search for the Project RenameOrMoveFileAdapter_file.jca file because in it we will change the component properties.
Stay tuned the <interaction-spec as we will change the ClassName and their properties, then only replace this line and the properties as follows:
<interaction-spec className="oracle.tip.adapter.file.outbound.FileIoInteractionSpec"> <property name="SourcePhysicalDirectory" value="/tmp"/> <property name="SourceFileName" value="arquivo.txt"/> <property name="TargetPhysicalDirectory" value="/tmp"/> <property name="TargetFileName" value="arquivo2.txt"/> <property name="Type" value="MOVE"/> </interaction-spec>
That done our open Processo BPEL:
In Variables… set the following variables:
- nomeArquivoOrigem type String
- diretorioOrigem type String
- nomeArquivoDestino type String
- diretorioDestino type String
- retornoSucesso type Integer
- retornoErro type Integer
Now into his drag a BPEL Assign and rename it to Variaveis_Entrada
Open this Assign and connect the variables of your left Request with the variables we created above that are the right and $retornoSucesso variable boot with 0, see below how it should be:
- $inputVariable.parameters/ns1:request/ns2:nomeArquivoOrigem call in $nomeArquivoOrigem
- $inputVariable.parameters/ns1:request/ns2:diretorioOrigem call in $diretorioOrigem
- $inputVariable.parameters/ns1:request/ns2:nomeArquivoDestino call in $nomeArquivoDestino
- $inputVariable.parameters/ns1:request/ns2:diretorioDestino call in $diretorioDestino
- Put zero 0 in $retornoSucesso
Drag a Invoke below its Assign Variaveis_Entrada and put the name Invoke_RenameOrMoveFileAdapter, then click the + in Input to create the Variable Input as below, then click OK.
Now click the Properties tab and click the + To and Name: choose option jca.file.FileName and in Variable select variable $nomeArquivoOrigem
Note: This is just a tactic to appear in our source code the properties that need to change.
Click OK up and its BPEL RenameOrMoveBPELProcess click on your Invoke_RenameOrMoveFileAdapter box and then click Source below:
Below the cursor will stay in his Invoke and then we have the code between the <bpelx: toProperty> as follows:
Now change this property with the following:
<bpelx:toProperty name="jca.file.SourceDirectory" variable="diretorioOrigem"/> <bpelx:toProperty name="jca.file.SourceFileName" variable="nomeArquivoOrigem"/> <bpelx:toProperty name="jca.file.TargetDirectory" variable="diretorioDestino"/> <bpelx:toProperty name="jca.file.TargetFileName" variable="nomeArquivoDestino"/> </bpelx:toProperties>
Here’s how it was:
Okay, now below its Invoke drag another Assign and put the name Variaveis_Saida.
Double click on Variaveis_Saida and turn the variable $retornoSucesso that is to your left side with $outputVariable.parameters/ns1:response/ns2:codigoRetorno on your right.
Note: In this example I am adding some variables retornoSucesso and retornoErro if necessary perform some error handling, however I will not make this post because it will not be our focus.
Create a file in any one location with the arquivo.txt file name and put something into this file to make sure that we will not move within this file.
In my case created in /home/uans/Arquivos
It is with the following content:
Make deploy your application
In your browser go to the address http://localhost:10000/em
Note: The port 10000 is the number that chose to create my Domain BPEL
Login:
Click on your project: FileAdapterUtilBPEL[1.0]
The screen right click Test
Then fill in as below and put the data where you created the file, in my case are as follows:
Note: See we’re renamingo arquivo.txt that is /home/uans/Arquivos to arquivoTeste.txt and we are movendo to the folder /home/uans/Arquivos/BKP
Then click on Test Web Service the upper right of the screen
Below the return of our service:
Doubts? Leave your comment and download this Projet
Hugs and see you next
/:-D
jose barros said:
works like a charm you are real good at those tutorials.
Uans said:
Thank you for access