You are on page 1of 19

Oracle EBS Service Invocation Framework

(Business Events SIF)

http://www.anilaltunkan.com/oracle-3/e-
business-suite-oracle/oracle-ebs-service-
invocation-framework-business-events-sif/

June 19, 2015 by altunkan in E-Business Suite, Oracle Workflow, PL/SQL

In this tutorial, I am going to invoke an external test web service with SIF.

SIF mechanism is based on events, therefore we are going to define business events and
subscriptions. After that, we can raise events in pl/sql.

You can find detailed information in the following link:


https://docs.oracle.com/cd/E18727_01/doc.121/e12169/T511175T513090.htm

We need to define business events for our request and response.

Request Business Event

1. Login to E-Business Suite. Select Business Events function under Workflow Administrator Web
(New) -> Administrator Workflo menu.
2. Click to Create Event button.

3. Fill the event information and click to Apply button.

4. Search for your event and click to Subscription icon.

5. Click to Create Subscription button.


6. Fill the subscription information and click to Next button. We are going to use this event
subscription for invoking web service. Phase parameter specifies whether the invoke process is
going to be synchronised or not. However, as far as I know, this parameter is only working for the
events which are raised in java. In this example, we are going to raise event in pl/sql, therefore it is
going to be queued in wf_java_deferred table. Data in message queue table is processed by an agent
listener periodically. Rule parameter should be Message since we are going to send a request
message to external service.

7. Type WSDL url for the external web service and click to Next button. SIF is going to parse WSDL
and display available services, ports, operations in web service.

8. Select Service and click to Next button.

9. Select Port and click to Next button.

10. Select Operation and click to Next button.


11. Fill Owner Name and Owner Tag for your subscription. Java Rule Function specifies invoking
java function. You can extend this class and write your own invoker if you need. Click to Apply
button.

12. We need to create a second subscription in request event. This is need for request errors and it is
going to launch WFERROR workflow which will send a notification about error details to the
SYSADMIN. Click to the Create Subscription button.

13. Choose Source Type as external since it is going to get the error for external service. Choose
Rule Data as Key. Click to the Next button.

14. Choose Workflow Type as WFERROR and Workflow Process as DEFAULT_EVENT_ERROR2.


Type owners and click to the Apply button.

Final view for request event:


Response Business Event

1. We are going to create a second event for service response. This event will capture service
response message. Click to the Create Event button.

2. Fill the event information and click to the


Apply button.

3. Search for event and click to Subscription icon.

4. Click to Create Subscription button.

5. Choose Rule Data as message and this action time will be Custom. Click to the Next button.

6. You can process response in java or pl/sql. We are going to create a pl/sql function which will fetch
event data. Pl/sql function should have a pre-defined skeleton. We will go into detail at next steps.
Click to the Apply button.
At this point, defining events and subscription process is completed.

EBS Service Agents

Make sure that following agents are up and running properly.

Web Services IN Agent

Web Services OUT Agent

Workflow Java Deferred Agent Listener (This is for JMS queue. Messages are going to be fetched
from WF_JAVA_DEFERRED table)

TABLE: xxanil_service_response

We are going to use this table for insering response of web service.

xxanil_service_response

Oracle PL/SQL

drop table xxanil_service_respo

create table xxanil_service_res


id number primary ke

2 drop table xxanil_service_response;

4 create table xxanil_service_response (


5 id number primary key,

6 event_key varchar2(80),

7 event_name varchar2(80),

8 response clob,

9 creation_date date

10 );

11

12 create sequence xxanil_service_response_s start with 1;

13

PROCEDURE: get_service_response

We are going to use this procedure for dml.

insert_service_reponse

Oracle PL/SQL

create or replace procedure ins


begin
insert into xxanil_service_res
commit;

2 create or replace procedure insert_service_reponse(p_response in clob, p_event_key in varchar2,


p_event_name in varchar2) is
3
begin
4
insert into xxanil_service_response values (xxanil_service_response_s.nextval, p_event_key,
5
p_Event_name, p_response, sysdate);
6
commit;
7 end;

FUNCTION: get_service_response

Pay attention to the skeleton of function. It must take two parameters subscription_guid in raw type
and event for in out nocopy wf_event_t type. We are going to specify response event name before
raising request event. After listeners finished their jobs, this function will be triggered by response
event with event data. We can fetch event key, event name, paramaters and event data from object.

get_service_response

Oracle PL/SQL

create or replace function get_s


p_subscription_guid
p_event in out noc
is

2 create or replace function get_service_response (

3 p_subscription_guid in raw,

4 p_event in out nocopy wf_event_t ) return varchar2

5 is

6 l_node varchar2(30);

7 l_version integer;

8 l_from varchar2(2000);

9 l_eventName varchar2(80);

10 l_eventkey varchar2(80);

11 l_paramlist wf_parameter_list_t;

12 l_eventData clob;

13 l_messageHandle varchar2(100);

14 begin

15 l_eventkey := p_event.GetEventKey();

16 l_eventName := p_event.getEventName();

17 l_paramList := p_event.getParameterList();

18 l_eventData := p_event.getEventData();

19 insert_service_reponse (l_eventData, l_eventKey, l_eventName);

20 return 'SUCCESS';

21 end get_service_response;
22

Create password key for secure services

If external service has security, then we need to pass wsse parameters in header of the request. SIF
does not allow us to modify wsse header in code. We need to create a password key (not
password) in database. To do this, we are going to give an application, key name and password.

Execute following script with your own credentials:

PASSWORD KEY

Oracle PL/SQL

declare
sysResp number;
appResp number;

2 declare

3 sysResp number;

4 appResp number;

6 l_module varchar2(30) := 'SQLAP'; --MODULE

7 l_key varchar2(30) := 'ANIL_KEY'; --KEY NAME

8 l_value varchar2(500) := '111111'; --PASSWORD

10 begin

11

12 -- get SYSTEM_ADMINISTRATOR resp and app ids for global init ..

13 begin

14 select RESPONSIBILITY_ID, APPLICATION_ID

15 into sysResp, appResp

16 from FND_RESPONSIBILITY

17 where RESPONSIBILITY_KEY = 'SYSTEM_ADMINISTRATOR';


18 fnd_global.apps_initialize( 0, sysResp, appResp);

19 exception

20 when others then

21 -- fail back to seeded values

22 fnd_global.apps_initialize(0,20420,1);

23 end;

24

25 fnd_vault.put(l_module, l_key, l_value);

26 end;

27 /

28 commit;

29

Raising the request event

We are going to raise request event in pl/sql with wf_event.raise api. We need to specify some
neccessary parameters.

Important Note: If your body and header xml requests using namespaces, you must move them to
body and header in a proper manner.

Variables

l_parameters: wf_parameter_list_t table type parameter. We are going to add parameters in this
variable with another API.

l_request_body: request body xml

l_request_header request header xml

l_event_key: raise key

variables

Oracle PL/SQL

l_parameters w f_parame
l_request_body clob;
l_request_header clob;
l_event_key varchar2 (5
1

2 l_parameters wf_parameter_list_t := wf_parameter_list_t ();

3 l_request_body clob;

4 l_request_header clob;

5 l_event_key varchar2 (50) := 'ANIL-TEST-5';

Adding Parameters

Parameter Name Description

WFBES_SOAP_USERNAME Standard parameter for wsse (security) username.

WFBES_SOAP_PASSWORD_MOD Standard parameter for our password key module.

WFBES_SOAP_PASSWORD_KEY Standard parameter for our password key name.

WFBES_CALLBACK_EVENT Callback event which will trigger response function.

WFBES_CALLBACK_AGENT Standard parameter for your agent. We are going to use "Web
Services IN Agent".

WFBES_INPUT_taicsheader Standard parameter for header.

WFBES_INPUT_header Standard parameter for header.

WFBES_INPUT_tAICSHeader Standard parameter for header.

adding parameters

OCaml
w f_event.addparametertolist
p_name => 'WFBES
p_value => 'ANIL',
p_parameterlist => l_para

2 wf_event.addparametertolist (

3 p_name => 'WFBES_SOAP_USERNAME',

4 p_value => 'ANIL',

5 p_parameterlist => l_parameters

6 );

8 wf_event.addparametertolist (

9 p_name => 'WFBES_SOAP_PASSWORD_MOD',

10 p_value => 'SQLAP',

11 p_parameterlist => l_parameters

12 );

13

14 wf_event.addparametertolist (

15 p_name => 'WFBES_SOAP_PASSWORD_KEY',

16 p_value => 'ANIL_KEY',

17 p_parameterlist => l_parameters

18 );

19

20 wf_event.addparametertolist (

21 p_name => 'WFBES_CALLBACK_EVENT',

22 p_value => 'XX_TEST_EVENT_RESPONSE',

23 p_parameterlist => l_parameters

24 );
25

26 wf_event.addparametertolist (

27 p_name => 'WFBES_CALLBACK_AGENT',

28 p_value => 'WF_WS_JMS_IN',

29 p_parameterlist => l_parameters

30 );

31

32 l_request_header := '<xx:SOAHeader
xmlns:xx="http://xmlns.oracle.com/apps/xx/soaprovider/plsql/xx_test_service/">
33
<xx:Responsibility>TR_PAYABLES_MANAGER</xx:Responsibility>
34
<xx:RespApplication>SQLAP</xx:RespApplication>
35
<xx:SecurityGroup>STANDARD</xx:SecurityGroup>
36
<xx:NLSLanguage>TURKISH</xx:NLSLanguage>
37
<xx:Org_Id/>
38
</xx:SOAHeader>';
39

40
wf_event.addparametertolist (
41
p_name => 'WFBES_INPUT_taicsheader',
42
p_value => l_request_header,
43
p_parameterlist => l_parameters
44
);
45

46
wf_event.addparametertolist (
47
p_name => 'WFBES_INPUT_header',
48
p_value => l_request_header,
49
p_parameterlist => l_parameters
50
);
51
52

53 wf_event.addparametertolist (

54 p_name => 'WFBES_INPUT_tAICSHeader',

55 p_value => l_request_header,

56 p_parameterlist => l_parameters

57 );

Adding body and raise

raise

Oracle PL/SQL

l_request_body := '<test:Inp
<test:PARAM
</test:InputParam

2 l_request_body := '<test:InputParameters
xmlns:test="http://xmlns.oracle.com/apps/xx/soaprovider/plsql/xx_test_service/test_function/"
3 >
4 <test:PARAM>123</test:PARAM>
5 </test:InputParameters>';
6

7 wf_event.raise (p_event_name => 'XX_TEST_EVENT_REQUEST',


8 p_event_key => l_event_key,
9 p_event_data => l_request_body,
1 p_parameters => l_parameters,
0
p_send_date => sysdate
1
1 );

1 commit;
2

1
3

Complete code:

Raise

Oracle PL/SQL

declare
l_parameters w f_parame
l_request_body clob;
l_request_header clob;

2 declare

3 l_parameters wf_parameter_list_t := wf_parameter_list_t ();

4 l_request_body clob;

5 l_request_header clob;

6 l_event_key varchar2 (50) := 'ANIL-TEST-5';

7 begin

8 wf_event.addparametertolist (

9 p_name => 'WFBES_SOAP_USERNAME',

1 p_value => 'ANIL',


0
p_parameterlist => l_parameters
1
1 );

1
2 wf_event.addparametertolist (
1 p_name => 'WFBES_SOAP_PASSWORD_MOD',
3
p_value => 'SQLAP',
1
4 p_parameterlist => l_parameters

1
5 );

1
6
wf_event.addparametertolist (
1
7 p_name => 'WFBES_SOAP_PASSWORD_KEY',

1 p_value => 'ANIL_KEY',


8 p_parameterlist => l_parameters
1 );
9

2
0 wf_event.addparametertolist (

2 p_name => 'WFBES_CALLBACK_EVENT',


1
p_value => 'XX_TEST_EVENT_RESPONSE',
2
p_parameterlist => l_parameters
2
);
2
3

2 wf_event.addparametertolist (
4
p_name => 'WFBES_CALLBACK_AGENT',
2
5 p_value => 'WF_WS_JMS_IN',

2 p_parameterlist => l_parameters


6
);
2
7
l_request_header := '<xx:SOAHeader
2
xmlns:xx="http://xmlns.oracle.com/apps/xx/soaprovider/plsql/xx_test_service/">
8
<xx:Responsibility>TR_PAYABLES_MANAGER</xx:Responsibility>
2
9 <xx:RespApplication>SQLAP</xx:RespApplication>

3 <xx:SecurityGroup>STANDARD</xx:SecurityGroup>
0
<xx:NLSLanguage>TURKISH</xx:NLSLanguage>
3
1 <xx:Org_Id/>

3
2 </xx:SOAHeader>';

3
3
wf_event.addparametertolist (
3
4 p_name => 'WFBES_INPUT_taicsheader',

3 p_value => l_request_header,


5 p_parameterlist => l_parameters
3 );
6

3
7 wf_event.addparametertolist (

3 p_name => 'WFBES_INPUT_header',


8
p_value => l_request_header,
3
p_parameterlist => l_parameters
9
);
4
0

4 wf_event.addparametertolist (
1
p_name => 'WFBES_INPUT_tAICSHeader',
4
2 p_value => l_request_header,

4 p_parameterlist => l_parameters


3
);
4
4
l_request_body := '<test:InputParameters
4
xmlns:test="http://xmlns.oracle.com/apps/xx/soaprovider/plsql/xx_test_service/test_function/"
5
>
4
<test:PARAM>123</test:PARAM>
6
</test:InputParameters>';
4
7

4 wf_event.raise (p_event_name => 'XX_TEST_EVENT_REQUEST',


8
p_event_key => l_event_key,
4
9 p_event_data => l_request_body,

5 p_parameters => l_parameters,


0
p_send_date => sysdate
5
1 );

5 commit;
2 end;
5
3

5
4

5
5

5
6

5
7

5
8

5
9

6
0

6
1

6
2

6
3

6
4

6
5

6
6

6
7

6
8

6
9

7
0

7
1

7
2

7
3

7
4

7
5

7
6

Check following link for raising event from Workflow:

https://blogs.oracle.com/ebusinesssuiteintegration/entry/invoking_web_service_from_orac_1

Check following link for raising event from OAF:

https://blogs.oracle.com/ebusinesssuiteintegration/entry/r121_-_invoking_web_service_fr

Tags: apps, business events, oracle, oracle apps, oracle ebs, sif, subscriptions, web service invoke,
WFBES_INPUT_header, WFBES_SOAP_PASSWORD_KEY

You might also like