In this chapter, we will cover the following recipes:
The Business Process Execution Language (BPEL) is based on XML, which means that all the internal variables and data are presented in XML. In this book, we cover both BPEL and Java. As both the technologies are complementary, we seek ways to ease the integration of the technologies. In order to handle the XML content from BPEL variables in Java resources (classes), we have a couple of possibilities:
oracle.xml.parser.v2.XMLElement input_cf= (oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/client:Cashflows");
We receive the XMLElement
class, which we need to handle further, either be assignment, reading of content, iteration, or something else.
xjc
utility and of course via the JDeveloper IDE. The example code for accessing XML through XML facade is:java.util.List<org.packt.cashflow.facade.PrincipalExchange> princEx= cf.getPrincipalExchange();
We can see that there is neither XML content nor DOM API anymore. Furthermore, we have to access the whole XML structure represented by Java classes.
The latest specification of JAXB at the time of writing is 2.2.7, and its specification can be found at the following location: https://jaxb.java.net/.
The purpose of an XML facade operation is the marshalling and un-marshalling of Java classes. When the originated content is presented in XML, we use un-marshalling methods in order to generate the correspondent Java classes. In cases where we have content stored in Java classes and we want to present the content in XML, we use the marshalling methods.
JAXB provides the ability to create XML facade from an XML schema definition or from the WSDL (Web Service Definition/Description Language). The latter method provides a useful approach as we, in most cases, orchestrate web services whose operations are defined in WSDL documents.
Throughout this chapter, we will work on a sample from the banking world. On top of this sample, we will show how to build the XML facade. The sample contains the simple XML types, complex types, elements, and cardinality, so we cover all the essential elements of functionality in XML facade.