How to Wrap Java Code as a SOAP Service

Incorporating Java and Java EE Code in a BPEL Process 13-3 } catch NamingException ne { addAuditTrailEntryne; } catch ClassNotFoundException cnfe { addAuditTrailEntrycnfe; } catch CreateException ce { addAuditTrailEntryce; } catch RemoteException re { addAuditTrailEntryre; } ]] bpelx:exec

13.2.4 How to Embed Java Code Snippets in a BPEL Process in BPEL 2.0

The examples in this chapter focus primarily on how to embed Java code snippets with the bpelx:exec extension. For BPEL projects that support version 2.0 of the BPEL specification, the syntax is slightly different. The bpelx:exec extension and Java code are wrapped in an extensionActivity element. Example 13–2 provides details. Example 13–2 bpelx:exec Extension in BPEL 2.0 extensionActivity bpelx:exec language=java [CDATA[ java code ]] bpelx:exec extensionActivity When you drag a Java Embedding activity into a BPEL process in Oracle BPEL Designer, the extensionActivity element and bpelx:exec tag are automatically added. Example 13–3 shows the import syntax for BPEL 2.0: Example 13–3 Import Syntax in BPEL 2.0 import location=classpackage name importType=http:schemas.oracle.combpelextensionjava Example 13–4 shows a BPEL file with two Java embedding activities for a project that supports BPEL version 2.0. Example 13–4 Java Embedding Activities in a BPEL File for Version 2.0 process name=Test targetNamespace=http:samples.otn.combpel2.0ch10.9 . . . . . . import location=oracle.xml.parser.v2.XMLElement importType=http:schemas.oracle.combpelextensionjava . . . sequence . . . extensionActivity bpelx:exec language=java XMLElement elem = XMLElement getVariableDataoutput, payload; elem.setTextContentset by java exec; bpelx:exec extensionActivity 13-4 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite extensionActivity bpelx:exec language=java [CDATA[XMLElement elem = XMLElement getVariableDataoutput, payload; String t = elem.getTextContent; elem.setTextContentt + , set by java exec 2;]] bpelx:exec extensionActivity . . . sequence process For information on using this activity, see Section 13.4, Using Java Embedding in a BPEL Process in Oracle JDeveloper.

13.2.5 How to Use an XML Facade to Simplify DOM Manipulation

You can use an XML facade to simplify DOM manipulation. Oracle BPEL Process Manager provides a lightweight Java Architecture for XML Binding JAXB-like Java object model on top of XML called a facade. An XML facade provides a Java bean-like front end for an XML document or element that has a schema. Facade classes can provide easy manipulation of the XML document and element in Java programs. You add the XML facade by using a createFacade method within the bpelx:exec statement in the .bpel file. Example 13–5 provides an example: Example 13–5 Addition of XML facade bpelx:exec name= ... [CDATA ... Element element = ... ElementgetVariableDatainput,payload,loanApplication: Create an XMLFacade for the Loan Application Document LoanApplication xmlLoanApp= LoanApplicationFactory.createFacadeelement; ...

13.2.6 How to Use bpelx:exec Built-in Methods

Table 13–1 lists a set of bpelx:exec built-in methods that you can use to read and update scope variables, instance metadata, and audit trails. Table 13–1 Built in Methods for bpelx:exec Method Name Description Object lookup String name JNDI access long getInstanceId Unique ID associated with each instance String setTitle String title String getTitle Title of this instance String setStatus String status String getStatus Status of this instance void setCompositeInstanceTitleString title Set the composite instance title