This recipe explains how to use XML facade inside BPEL processes. We can use XML façade to simplify access of XML content from Java code. When using XML façade, the XML content is exposed over Java code.
To complete the recipe, there are no special prerequisites. Remember that in the Packaging XML facade into JAR recipe, we defined the ANT task to copy XML facade to the BPEL process library directory. This task basically presents all the prerequisites for XML facade utilization.
Open a BPEL process (Derivative_Cashflow.bpel
) in JDeveloper and insert the Java Embedding activity into it:
try {
oracle.xml.parser.v2.XMLElement input_cf= (oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/client:Cashflows");
Object obj_cf = facade.Facade.createFacade("org.packt.cashflow.facade", input_cf);
javax.xml.bind.JAXBElement<org.packt.cashflow.facade.CashflowsType> cfs = (javax.xml.bind.JAXBElement<org.packt.cashflow.facade.CashflowsType>)obj_cf;
JAXBElement
content class:org.packt.cashflow.facade.CashflowsType cf= cfs.getValue();
} catch (Exception e) { e.printStackTrace(); addAuditTrailEntry("Error in XML facade occurred: " + e.getMessage()); }
Actually, the execution of the BPEL process will not produce any output, since we have no output lines defined. In case some exception occurs, we will receive information about the exception in the audit trail as well as the BPEL server console.
We add the XML facade JAR file to the BPEL process library directory (<BPEL_process_home>SCA-INFlib
). Before we are able to access the XML facade classes, we need to extract the XML content from the BPEL process. To create the Java representation classes, we transform the XML content through the JAXB context. As a result, we receive an un-marshalled Java class ready to be used further in Java code.