Invoking Web Service from Oracle Workflow process
By Vijay Shanmugam-Oracle on Jul 26, 2009
IntroductionIntegrated SOA Gateway (ISG) in Oracle EBusiness Suite 12.1 provides Service Invocation Framework (SIF) to natively consume and invoke web services. SIF uses Oracle Workflow Business Event System to provide necessary infrastructure to consume an abstract Web Service and dynamically invoke the Web Service without requiring any design-time code generation. In this blog post we will see a specific use case of how to invoke web services from an Oracle Workflow process that is designed using Oracle Workflow Builder and executed in the database by the Oracle Workflow Engine.
SIF setupPlease refer to 12.1 ISG Developer Guider topic "Defining Web Service Invocation Metadata" under chapter "Working With Oracle Workflow Business Event System to Invoke Web Services" for detailed information on creating Business Event System meta-data. A summary of the steps are given below.
- Create an Invoker Business Event.
- Create a Local Subscription of Action Type "Invoke Web Services" to the invoker event.
- Create an Error subscription to the invoker event to handle any errors during invocation is also required.
- Create a callback business event and set it as part of the "Invoke Web Services" Local subscription.
- Specify a callback agent such as WF_JMS_IN to which the callback event can be enqueued. You can create and use any workflow agent to receive the response.
- Create an External subscription to the callback event to handle the web service response from WF_JMS_IN.
Invoking from Workflow ProcessWorkflow processes include standard event activities such as Raise event and Receive event. Since Workflow processes execute within the database we will use the PLSQL message pattern discussed above to invoke the web service from workflow processes. Following steps are required to successfully invoke web service from workflow process using SIF.
Create Raise Event activity
Use Raise Event activity to raise the invoker event. A function activity can be used to create input message required for the web service and set to the invoker event payload.
Create a Receive Event activity
Use a Receive Event activity to receive the callback event in the workflow process. Callback event is raised after successful invocation of web service by Java Deferred Agent Listener.
Create an External Subscription to the callback event
Create an External subscription to the callback event with Workflow Type and Workflow Process set to the workflow process waiting to receive the web service response. The External subscription can also be used to simply execute a rule function to process the web service response.
Code SampleAbove use case is explained using a sample Workflow Process with required Business Event System meta-data. You may download the sample code for testing.
- WFINVTSTE.wfx - Invoker Event and Callback (Receive) Event
- WFINVTSTS.wfx - Local "Invoke Web Service" Subscription to Invoker Event, Error Subscription to Invoker Event, External Subscription to Callback Event
- WFINVTST.wft - The Workflow process that raises the Invoker Event and Receives the Callback Event
- WFINVTSTS.pls - PLSQL spec for function activities used in above Workflow Process
- WFINVTSTB.pls - PLSQL body for function activities used in above Workflow Process
Instructions to use sample
- Upload *.wfx files using Workflow Business Event System loader program oracle.apps.fnd.wf.WFXLoad
- Upload *.wft file using Workflow Definitions Loader $FND_TOP/bin/WFLOAD
- Compile *.pls files to APPS schema
- Verify Workflow Java Deferred Agent Listener is up and running
- Launch Workflow using LAUNCH.sql script. The workflow process sends a notification with the web service response to a specified recipient after successful invocation of web service.
- Wait until Workflow Java Deferred Agent Listener completes execution of the "Invoke Web Service" subscription and enqueues response to WF_JMS_IN agent.
- Configure an Agent Listener to run against WF_JMS_IN or another appropriate Callback Agent that you want to use to listen to callback events. An easy way to run listener is exececute PLSQL API WF_EVENT.Listen from sqlplus connected to APPS schema.