Scenario - Invoke a composite via EJB passing a complex payload.
My payload is as follows -
I create a synchronous BPEL process that accepts inputOrder as input/output.
all the BPEL process does is Assign In 2 Out.
I then create an EJB Service (Generate Java interface from WSDL)
Wire together
Review the classes that have been created.
Make InputOrder and OrderType serializable
public class InputOrder implements Serializable{
public class OrderType implements Serializable{
Change the interface (BPELOrderProcess) to get rid of Holder dependency (I had
serialization issues with javax.xml.ws.Holder)
public void process(@WebParam(targetNamespace="http://www.example.org",
partName="payload", name="inputOrder", mode=Mode.INOUT)
bpelorderprocess.complexpayloadejbservice.complexpayloadejbservice_app.com.oracle.xmlns.InputOrder payload);
}
Deploy to SOA Server
Check the JNDI tree using the WLS console to see if our EJB is visible.
Create the EJB Client - I did this in the same project to save time -
Actual Code -
public class MyEJBClient {
public static void main(String [] args) throws Throwable {
try {
final Context context = getInitialContext();
Proxy proxy = (Proxy)context.lookup("ejb/BPELOrderProcessService");
// preparing the method to be called on the remote EJB
Method method =
BPELOrderProcess.class.getDeclaredMethod("process", new Class[] {InputOrder.class});
InputOrder id = new InputOrder();
id.setKey(12345);
id.setCustName("NiallC");
OrderType ot = new OrderType();
ot.setComments("Good Customer");
ot.setProduct("Oracle SOA Suite 11g");
ot.setProductGroup("FMW");
ot.setProductKey(new Long(12345));
id.setOrder(ot);
InvocationHandler handler = Proxy.getInvocationHandler(proxy);
InputOrder response = (InputOrder)handler.invoke(proxy, method, new Object[] { id });
} catch (Exception ex) {
ex.printStackTrace();
}
}
private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
// WebLogic Server 10.x connection details
env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new InitialContext( env );
}
}
Add the Weblgic Thin Client Library to the project
Run the client
Check the instance in em
No comments:
Post a Comment