Tuesday, November 5, 2019

12c SOA - Move file using file adapter

Here i will show how to move file from one location to other without reading its content using file adapter.

Implementation steps:
Create a SOA Project


 Choose Composite with One way BPEL Process


 Right click on right swim lane and choose file adapter 



 Choose Operation Type as "Synchronous Read file"
 Provide a dummy directory and file name

 Here we will choose Opaque schema as we will not read the file content.

 Wire the the adpater with the BPEL process
 Open the JCA file
 Modify it as per below
 <adapter-config name="fileMoveAdapter" adapter="file" wsdlLocation="../WSDLs/fileMoveAdapter.wsdl"
                xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
  <connection-factory location="eis/FileAdapter"/>
  <endpoint-interaction portType="SynchRead_ptt" operation="SynchRead">
    <!--interaction-spec className="oracle.tip.adapter.file.outbound.FileReadInteractionSpec">
      <property name="PhysicalDirectory" value="dummy"/>
      <property name="FileName" value="dummy"/>
      <property name="DeleteFile" value="true"/>
    </interaction-spec-->
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileIoInteractionSpec">
      <property name="SourcePhysicalDirectory" value="SourceDirectory"/>
      <property name="SourceFileName" value="SourceFileName.txt"/>
      <property name="TargetPhysicalDirectory" value="TargetDirectory"/>
      <property name="TargetFileName" value="TragetFileName.txt"/>
      <property name="Type" value="MOVE"/>
    </interaction-spec>
  </endpoint-interaction>
</adapter-config>
Create following 4 variables and assign the the real values.
    <variable name="sourceDirectory" type="xsd:string"/>
    <variable name="sourceFileName" type="xsd:string"/>
    <variable name="targetDirectory" type="xsd:string"/>
    <variable name="targetFileName" type="xsd:string"/>

 Invoke the file adapter partnerlink and add the JCA properties in the properties tab:

<invoke name="Invoke_fileMoveAdapter" partnerLink="fileMoveAdapter"
            portType="ns1:SynchRead_ptt" operation="SynchRead"
            inputVariable="Invoke_fileMoveAdapter_SynchRead_InputVariable"
            outputVariable="Invoke_fileMoveAdapter_SynchRead_OutputVariable" bpelx:invokeAsDetail="no">
      <bpelx:toProperties>
        <bpelx:toProperty name="jca.file.SourceDirectory" variable="sourceDirectory"/>
        <bpelx:toProperty name="jca.file.SourceFileName" variable="sourceFileName"/>
        <bpelx:toProperty name="jca.file.TargetDirectory" variable="targetDirectory"/>
        <bpelx:toProperty name="jca.file.TargetFileName" variable="targetFileName"/>
      </bpelx:toProperties>
    </invoke>
 Deploy the composite and place the file in the source directory and you test it.


No comments:

Post a Comment

Featured Post

OIC - "Dynamically Configuring Relative URLs for REST API Invocations in Oracle Integration Cloud" | Dynamically invoke local integration

Use Case: In Oracle Integration Cloud (OIC), there is often a need to dynamically determine the Relative URI while invoking REST APIs. This ...