Pages

Sunday, December 2, 2007

ADF taskflow with WS method call + router

ADF taskflow supports indirect web services. This gives us new possibilities such as calling esb and bpel web services or integrating a normal web service in our flow. Integrating web services in our taskflow is easy. You can do it in 3 steps. The first step is done by making a web service proxy or much easier an web service datacontrol. The second step is making a taskflow method call (drop the datacontrol method on the taskflow) and the last step evaluating the result of the method call by using a taskflow router.
This blog gives you a guide to do this. This example is a credit check if you put in the start page a value below 200 then it is approved and above 200 it is declined. The credit is done with a router and with a method call /router.
First we create a fusion project. Now we have an empty adfc-config.xml, this is the unbounded taskflow. In this taskflow I create 3 views start, approved and declined. On the pages approved and declined I only put in an outputtext with approved or declined.
This is the start page.


In the taskflow routing and in the start page I use the following simple backing bean.

I put this bean in the adfc-config as a pageFlow managed bean. The price variable is used for the start page inputtext and the isapproved method for the router priceCheck. We are ready to drop now a router on the adfc-config.xml

In this taskflow you are already see the web server method call. I will explain this later in this blog. Let's look at the properties of the router priceCheck.

The default outcome is declined, this value is used when StartPage.approved = false when this is true then the outcome is approved. We are ready with the router example.

Let's make it a little bit interesting by calling a web service which does the credit check. We make a new empty project in the same workspace. Make a java class with a method which has 1 parameter price and it returns true when the price is below 200 else false. Create a web service on this method and deploy this on the oc4j server in the jdeveloper home. We go back to the viewcontroller project where we create a web service datacontrol on this web service. We drop the created datacontrol on the taskflow. Now automatically a method call with a pagedef is created.
I only have to fill in the fixed outcome so the control flow case goes the router where the result of the ws is evaluated.

We have the store the result of the web service in a variable so the router can used it.

The router is almost the same as the first router. We are ready to test it.

Here you have the example project. To run it you have to deploy the web service to the jdeveloper oc4j server first.

2 comments:

  1. Hi Edwin,
    where is a adf desktop integration jar?
    Error:
    weblogic.application.ModuleException: Failed to load webapp: 'adf_security2-ViewController-context-root'
    java.lang.ClassNotFoundException: oracle.adf.desktopintegration.servlet.DIRemoteServlet
    I'm using JDeveloper Studio Edition Version 11.1.1.0.2.
    Thank you your help!
    Laci

    ReplyDelete
  2. Hi,

    This is for excel and adf communication. this demo is build with a TP release , you can remove the servlet and adf di library.

    thanks Edwin

    ReplyDelete