Tuesday, 8 May 2012

Convert xsd:anyType data into XML Data

Recently I encountered this requirement to Accept AnyType Data and convert it into a valid xml data.

Few important things to consider is: The AnyType data payload should be a valid one with the namespaces defined.The type to be converted to should be declared in an xsd.

In my process I had to get this anyType data and convert it to a format with which I had to invoke a service.
Though it sounds very simple I felt its better to document it in a very easily accessible way. I followed the following steps for the same in SOA 11.1.1.4:

  1. Create 2 variables to which you want to convert the anytype Data to.
  2. Use the following function to Parse the value:oraext:parseXML(bpws:getVariableData('inputVariable','request','/ns2:Request/ns2:Details/ns2:xmlData')) where xmlData is of datatype Any.Please note that when you are selecting the anyType data, in Assign activity this will not get copied in the expression builder, hence you need to manually add this data.
  3. Once this Assign activity is completed, use Assign or Transform activity to transform the values within the xml generated in the above mentioned step to another variable which is used to invoke the service.
I hope this helps for people looking for usage of oraext:parseXML.


Dynamically Set Archive Drectory Location for FTP Transfer

In Some of the scenarios of FTP File transfer in a typical BPEL Process, we might need to set the location of Archive Directory  dynamically, either by picking from some configuration properties file or from the payload at runtime. To achieve this we need to follow the below mentioned steps:

  1. In FTP WSDL file set the jca properties to select logical directories for Archive or source file location directory.Also Set the property "UseRemoteArchive"  to true.  
              <jca:operation FileType="binary"
              LogicalDirectory="directory"
              InteractionSpec="oracle.tip.adapter.ftp.outbound.FTPReadInteractionSpec"
              LogicalArchiveDirectory="FileArchiveDirectory"
              DeleteFile="true"
              FileName="fileName"
              OpaqueSchema="true"
              UseRemoteArchive="true" >
  2. In the BPEL service flow, when we invoke the FTP adapter to either get/put files, we can see that bpel.xml file gets update with the partner link binding details. In the partner link binding details keep the values blank for LogicalArchiveDirectory.                                                                                                      <property name="FileArchiveDirectory" type="LogicalArchiveDirectory"></property>.
  3. However we can set the outbound directory location by using ftpAdapterOutboundHeader. We cannot do the same for the Archive Directory. Hence we will use the following function in the JavaEmbedding to set the ArchiveDirectory.                                      Location.getLocator().lookupProcess("<<ProcessName>>").getDescriptor().getPartnerLinkBindings().getPartnerLinkBinding("<<PartnerLinkBindingName>>").setPropertyValue("FileArchiveDirectory",(String)getVariableData("archiveDir"));  
    }    
    catch(Throwable ex){  
    addAuditTrailEntry("Exception - " + ex.getMessage());  
    }    
                          This way we can set the Archive Directory Location in the bpel.xml file dynamically  where getVariableData("archiveDir") is the archive directory location variable set in the bpel flow.