Tags
For this our example we will use our previous project where I have Moved or Renamed a file, and now in this post we will create another operation to Delete the file.
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
We will now update the WSDL of our FileAdapterUtilBPEL project so far has the new operation deleteFile.
Then replace the WSDL for our project by clicking FileAdapterUtilBPEL here
Made it just re-open the composite.xml and the new operation will appear on your Service Exposed automatically as follows:
Note: If your composite.xml it was already open, close it and open it again.
Now into his composite.xml drag a component called Mediator and name of FileUtilMediator
In Template leave marked the Define Interface Later option as below and click OK.
Note: The Mediator is responsible for telling the BPEL which operations should be called.
Now delete the line that connects your WebService Exposed with your BPEL and turn our Mediator with this Service Exposed and its BPEL
When making the Mediator connection to the BPEL choose the options below:
- Mediator Operation –> renameOrMoveFile
- Target Operation –> renameOrMoveFile
Click OK and will be as follows:
Double-click on your Mediator
Below be aware that sometimes can occur a problem where deleteFile operation appears operation RenameOrMoveBPELProcess:
If your are also so, then you must delete this transformation and then create again the right way. To do this click on the X next
Confirm your decision:
Will be as follows:
Then create a transformation for the operation renameOrMoveFile:
Beside the operation renameOrMoveFile click the + sign on your right and then click static routing rule
Click below Service
Now click renameOrMoveFile:
Feito isso veja abaixo como deverá ficar:
Note: Watch the screen above, see for that operation must appear in renameOrMoveFile operation RenameOrMoveBPELProcess/renameormovebpelprocess_client::renameOrMoveFile
Note 2: Devera appear parameters : <<Transformation Map>> the both Transform Using and this part should not be blank, if then delete again the transformation and create again as we did above
Go back to your composite.xml and drag a File Adapter to create our delete operation and name of DeleteFileAdapter
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 Next
Check the Native format translation is not required
Click Finish
In his search for the Project DeleteFileAdapter_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="TargetPhysicalDirectory" value="/tmp"/> <property name="TargetFileName" value="lixo.txt"/> <property name="Type" value="DELETE"/> </interaction-spec>
Drag a Process BPEL component, and check the options as follows:
- Choose option BPEL 2.0 Specification
- Name it DeleteFileBPELProcess
- In Template select Base on a WSDL
- In Service Name place deleteFile
- Uncheck the flag Expose as a SOAP serivice
- In WSDL URL look for the WSDL that lowered: FileUtilContract.wsdl
Like this:
Now connect your Mediator to this BPEL and then your BPEL to DeleteFileAdapter
In the following screen choose the option deleteFile
So it looks like this:
That done our open Processo BPEL do DeleteFileBPELProcess
In Variables… set the following variable:
- nomeArquivo type String
- nomeDiretorio 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/ns3:nomeArquivo call in $nomeArquivo
- $inputVariable.parameters/ns1:request/ns3:diretorio call in $nomeDiretorio
- Put zero in 0 $retornoSucesso
Drag a Invoke below its Assign Variaveis_Entrada and put the name of Invoke_DeleteFileAdapter, then click the + sign in Input to create the input variable as indicated below, then click OK.
Now click the Properties tab and click the + To and Name: Choose jca.file.FileName option and select the variable Variable $nomeArquivo
Note: This is just a tactic to appear in our source code the properties that need to change.
Click OK up and its BPEL DeleteFileBPELProcess click on your Invoke_DeleteFileAdapter box and then click Source below:
Below the cursor will stay in his Invoke and then we have the code between tag <bpelx:toProperty> as below:
Now change this property with the following:
<bpelx:toProperties> <bpelx:toProperty name="jca.file.TargetFileName" variable="nomeArquivo"/> <bpelx:toProperty name="jca.file.TargetDirectory" variable="nomeDiretorio"/> </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/ns3:codigoRetorno on your right and then click OK
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.
Make Deploy your project to test our project
After successful Deploy Project, create a file in a place with no name arquivo.txt
In my case I created in /home/uans/Arquivos
Then click on Test Web Service the upper right side of the screen
Below the return of our service:
Return the directory where was the .txt file and you will see that it is no longer there
Doubts? Leave your comment and download this Projet
Hugs and see you next
/:-D