BPEL

Working with FileAdapter in BPEL – Part 5: Deleting a file

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:

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

Imagem Blog UansCarvalho

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.

Imagem Blog UansCarvalho

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.

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

Click OK and will be as follows:

Imagem Blog UansCarvalho

Double-click on your Mediator

Below be aware that sometimes can occur a problem where deleteFile operation appears operation RenameOrMoveBPELProcess:

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

Confirm your decision:

Imagem Blog UansCarvalho

Will be as follows:

Imagem Blog uansCarvalho

Then create a transformation for the operation renameOrMoveFile:

Beside the operation renameOrMoveFile click the + sign on your right and then click static routing rule

Imagem Blog UansCarvalho

Click below Service

Imagem Blog UansCarvalho

Now click renameOrMoveFile:

Imagem Blog UansCarvalho

Feito isso veja abaixo como deverá ficar:

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

Leave checked the Define from operation and schema (specified later)

Imagem Blog UansCarvalho

Below check the Write

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

Check the Native format translation is not required

Imagem Blog UansCarvalho

Click Finish

Imagem Blog UansCarvalho

In his search for the Project DeleteFileAdapter_file.jca file because in it we will change the component properties.

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

Like this:

Imagem Blog UansCarvalho

Now connect your Mediator to this BPEL and then your BPEL to DeleteFileAdapter

In the following screen choose the option deleteFile

Imagem Blog UansCarvalho

So it looks like this:

Imagem Blog UansCarvalho

That done our open Processo BPEL do DeleteFileBPELProcess

Imagem Blog UansCarvalho

In Variables… set the following variable:

  • nomeArquivo type String
  • nomeDiretorio type String
  • retornoSucesso type Integer
  • retornoErro type Integer

Imagem Blog UansCarvalho

Now into his drag a BPEL Assign and rename it to Variaveis_Entrada

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

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.

Imagem Blog UansCarvalho

Now click the Properties tab and click the + To and Name: Choose jca.file.FileName option and select the variable Variable $nomeArquivo

Imagem Blog UansCarvalho

Note: This is just a tactic to appear in our source code the properties that need to change.

Imagem Blog UansCarvalho

Click OK up and its BPEL DeleteFileBPELProcess click on your Invoke_DeleteFileAdapter box and then click Source below:

Imagem Blog UansCarvalho

Below the cursor will stay in his Invoke and then we have the code between tag <bpelx:toProperty> as below:

Imagem Blog UansCarvalho

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:

Imagem Blog UansCarvalho

Okay, now below its Invoke drag another Assign and put the name Variaveis_Saida.

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

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

Imagem Blog UansCarvalho

Then click on Test Web Service the upper right side of the screen

Imagem Blog UansCarvalho

Below the return of our service:

Imagem Blog UansCarvalho

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

 

 

Criei este Blog destinado a desenvolvedores e interessados na Tecnologia Oracle SOA Suite, minha idéia é que no futuro ele sirva de referência para Analistas e Desenvolvedores desde aprendizes a especialistas. Já existem alguns Posts interessantes que abordam um pouco do meu dia a dia, no passar do tempo irei alimentar este Blog com o máximo de informações possíveis, por isso peço por gentileza aos interessados e afins que caso tenham alguma dúvida, sugestão ou crítica que me digam para que eu possa da melhor forma suprir as expectativas e na medida do possível sanar todas as duvidas que vierem a surgir ou até mesmo criar novos Posts abordando algum tópico que venha a ser relevante para todos os interessados. Obrigado Uans Carvalho

Leave a Reply

Your email address will not be published. Required fields are marked *