Thursday, July 29, 2010

Oracle SOA 11g Human Task Query Service Remote Client

In my previous post I provided a link which has a sample code which uses the ITaskQueryService to query and act upon Human Tasks. The sample code provided over there used SOAP_CLIENT to establish connection to the server but if you wish to use the REMOTE_CLIENT below is the code snippet.


           WorkflowServicesClientConfigurationType wscct =
                new WorkflowServicesClientConfigurationType();
            wscct.setClientType(WorkflowServiceClientFactory.REMOTE_CLIENT);
            List servers = wscct.getServer();
            ServerType server1 = new ServerType();
            server1.setDefault(true);
            server1.setName("HcmSOAServer");
            servers.add(server1);

          
            RemoteClientType rct1 = new RemoteClientType();
            rct1.setServerURL("t3://ss-cmpq02.us.oracle.com:8001");
            rct1.setInitialContextFactory("weblogic.jndi.WLInitialContextFactory");
            rct1.setParticipateInClientTransaction(false);
            server1.setRemoteClient(rct1);

            IWorkflowServiceClient client =
                WorkflowServiceClientFactory.getWorkflowServiceClient(wscct, null);
            ITaskService taskSvc = client.getTaskService();
            ITaskQueryService taskQuerySvc = client.getTaskQueryService();          
            IWorkflowContext ctx = taskQuerySvc.authenticate("employee", "Welcome1".toCharArray(), "jazn.com");

Oracle SOA 11g Human Task Query Service

In Oracle SOA Suite 11g, a set of APIs are provided to query and act upon the Human Tasks programmatically. A sample code is provided in ITaskQueryService javadoc. In future if the link is broken just google for ITaskQueryService and most probably the first link would be the latest javadoc.

Wednesday, July 28, 2010

Navigating within Task Flow activities programmatically

Using the NavigationHandler Class we can programmatically navigate to a different activity based on an action within an ADF Task Flow. Sample code below:


    public void navBasedOnAction(String action){
        NavigationHandler navHndlr = FacesContext.getCurrentInstance().getApplication().getNavigationHandler();
         navHndlr.handleNavigation(FacesContext.getCurrentInstance(), null , "finish");
    }



Invoking Method Binding Programmatically

The following code snippet can be used to invoke a method binding programmatically from java:

public void invokeMB(String mBinding){
    FacesContext fctx = FacesContext.getCurrentInstance();
    ExpressionFactory ef = fctx.getApplication().getExpressionFactory();
    ELContext elCtx = fctx.getELContext();
    ValueExpression valueExp = ef.createValueExpression(elCtx,"#{bindings}",Object.class);
    JUFormBinding a = (JUFormBinding)valueExp.getValue(elCtx);
    OperationBinding op = (OperationBinding)a.getOperationBinding(mBinding);
    op.execute();
}

Invoking Web Services in Oracle ADF

There are two ways to invoke a Web Service in an ADF Application:
1. JAX-WS Proxy
2. Web Service Data Control

JAX-WS Proxy
Just by providing the wsdl to the Create WebService Proxy wizard you can easily generate the proxy to invoke the webservice. More details on this can be found on my earlier post.
Pros:
Gives more flexibility and control to the WebService consumer. The developer can create webservice request object and can invoke the webservice as required. The proxy can also be wrapped as a DataControl (right click on the client java file and select Generate Data Control) and used in ADF.
Cons:
Maintanence is hard. Generates many files to support the proxy and the proxy has to be regenerated if the WSDL stucture changes.

Web Service Data Control
In the New Gallery select Web Service Data Control and provide the wsdl location in the wizard to generate the Data Control. Once the DataControl is generated it can be used on like any other datacontrol and the webservice's operations can be performed in ease. For eg, a button click on a page / method on taskflow.
Pros:
Easy to create and use.
Cons:
Limited control over invoking the webservice.