Solved

How to grap the Application Message response?

  • 20 May 2020
  • 8 replies
  • 235 views

Userlevel 2
Badge +5

Hi,

I have send out an Application Message from IFS to an external API endpoint using a HTTP connector.

I have reaced the endpoint succesfully.

The endpoint returned me back a message and IFS is showing it to med in a .txt file.

How can I access that response, and have is saved somewhere in the database?

Any help is very appreciated.

Kresten

icon

Best answer by dsj 22 May 2020, 16:03

Elaborating the answer by @Tomas Ruderfelt , here’s what I have done in a similar scenario where I had to process the reply from an external web service in Apps9 without doing any code modification :wink:

In my scenario, I’m getting the currency rates from an external API and update IFS currencies.

1: Create an event on FNDCN_APPLICATION_MESSAGE_TAB based on STATE field

 

Event Action: remember to add proper conditions just to trigger the action only for your integration, and state = Finished

This calls another event in a background job. Reason for taking this approach is the message reply is not commit at this time so we can’t access it directly from the event action on FNDCN_APPLICATION_MESSAGE_TAB

 

Code:

declare

  event_enabled_ BOOLEAN := Event_SYS.Event_Enabled('Event','CURRENCY_UPD_EXECUTE');

  parameters_    VARCHAR2(32000);

  event_msg_     VARCHAR2(32000);

  id_            NUMBER;

begin

  IF event_enabled_ THEN

    Fnd_Session_API.Impersonate_Fnd_User(fnd_session_api.get_app_owner);

    event_msg_ := Message_SYS.Construct('CURRENCY_UPD_EXECUTE');

    Message_SYS.Add_Attribute(event_msg_,'APPLICATION_MESSAGE_ID','&NEW:APPLICATION_MESSAGE_ID');

    Client_SYS.Add_To_Attr('EVENT_LU_NAME_', 'Event', parameters_);

    Client_SYS.Add_To_Attr('EVENT_ID_','CURRENCY_UPD_EXECUTE',parameters_);

    Client_SYS.Add_To_Attr('EVENT_DATA_', event_msg_, parameters_);

  

    Transaction_SYS.Deferred_Call(id_,'EVENT_SYS.EVENT_EXECUTE','PARAMETER',parameters_,'Process cureency XML');

    Fnd_Session_API.Reset_Fnd_User;

  END IF;

end;

 

Script to create the CURRENCY_UPD_EXECUTE event:

 

BEGIN

   Event_SYS.Enable_Event('Event', 'CURRENCY_UPD_EXECUTE',

                          'Execute Currency XML',

   'APPLICATION_MESSAGE_ID/STRING^');

END;

 

Now we can create an event action for this event to do the real work.

Reply from the external web service is stored as a blob in  MESSAGE_VALUE column in fndcn_message_body_tab

 select MESSAGE_VALUE from fndcn_message_body_tab

   where application_message_id = '&APPLICATION_MESSAGE_ID'

   and REPLY = 1;

 

 

 

after this point, it’s converting reply to xml (or json) and process via standard plsql logic.

 

Hope it helps!

View original

8 replies

Userlevel 4
Badge +7

Hi Kresten,

I haven’t used this process so this is just a guess...

Create a Routing Rule for the READER_RESPONSE queue and configure an output such as To File.

I’ll try this and see if it works...

Userlevel 4
Badge +7

And you can access the READER_RESPONSE messages in Application Messages.

 

Userlevel 2
Badge +5

The response doesn’t come as an application message.

I don’t have the READER_RESPONSE queue, and it doesn’t show in any other queue.

I’m not sure how to handle this...

Userlevel 3
Badge +5

If you want the technical info to use in Lobby/Event/Quick Report etc.:

The response(s) to an application message is saved in table fndcn_message_body_tab with column REPLY set to 1.

There is a view MESSAGE_BODY which shows the records from that table which you shall use instead of the table directly. 

Userlevel 6
Badge +11

Elaborating the answer by @Tomas Ruderfelt , here’s what I have done in a similar scenario where I had to process the reply from an external web service in Apps9 without doing any code modification :wink:

In my scenario, I’m getting the currency rates from an external API and update IFS currencies.

1: Create an event on FNDCN_APPLICATION_MESSAGE_TAB based on STATE field

 

Event Action: remember to add proper conditions just to trigger the action only for your integration, and state = Finished

This calls another event in a background job. Reason for taking this approach is the message reply is not commit at this time so we can’t access it directly from the event action on FNDCN_APPLICATION_MESSAGE_TAB

 

Code:

declare

  event_enabled_ BOOLEAN := Event_SYS.Event_Enabled('Event','CURRENCY_UPD_EXECUTE');

  parameters_    VARCHAR2(32000);

  event_msg_     VARCHAR2(32000);

  id_            NUMBER;

begin

  IF event_enabled_ THEN

    Fnd_Session_API.Impersonate_Fnd_User(fnd_session_api.get_app_owner);

    event_msg_ := Message_SYS.Construct('CURRENCY_UPD_EXECUTE');

    Message_SYS.Add_Attribute(event_msg_,'APPLICATION_MESSAGE_ID','&NEW:APPLICATION_MESSAGE_ID');

    Client_SYS.Add_To_Attr('EVENT_LU_NAME_', 'Event', parameters_);

    Client_SYS.Add_To_Attr('EVENT_ID_','CURRENCY_UPD_EXECUTE',parameters_);

    Client_SYS.Add_To_Attr('EVENT_DATA_', event_msg_, parameters_);

  

    Transaction_SYS.Deferred_Call(id_,'EVENT_SYS.EVENT_EXECUTE','PARAMETER',parameters_,'Process cureency XML');

    Fnd_Session_API.Reset_Fnd_User;

  END IF;

end;

 

Script to create the CURRENCY_UPD_EXECUTE event:

 

BEGIN

   Event_SYS.Enable_Event('Event', 'CURRENCY_UPD_EXECUTE',

                          'Execute Currency XML',

   'APPLICATION_MESSAGE_ID/STRING^');

END;

 

Now we can create an event action for this event to do the real work.

Reply from the external web service is stored as a blob in  MESSAGE_VALUE column in fndcn_message_body_tab

 select MESSAGE_VALUE from fndcn_message_body_tab

   where application_message_id = '&APPLICATION_MESSAGE_ID'

   and REPLY = 1;

 

 

 

after this point, it’s converting reply to xml (or json) and process via standard plsql logic.

 

Hope it helps!

Userlevel 2
Badge +5

Thanks, I have been looking for this solution for a very long time.

Userlevel 6
Badge +11

Thanks, I have been looking for this solution for a very long time.

My pleasure to help!.

In Apps 10, there’s a new feature to call a PLSQL method directly to process the response so you don’t need this workaround :)

 

/Damith

Userlevel 2
Badge +5

We are waiting for this upgrade :)

Reply