Skip to main content

Hi,

I need to send a document to an external REST API from IFS 9.

I can send an XML string to a REST API by routing an application message to HTTP.

But Is there any way I can attach a document to an application message?

 

I need this to send an invoice to an external shipping broker.

Hi @krestensb ,

You can convert the document into base64 string and add as a CDATA section in the XML.

 


Thanks! I’ll try that.

You wrote a guide on how to to create XML from PLSQL with DBMS_XMLDOM. I’ll take that approch.

(https://dsj23.me/2019/09/18/how-to-use-dbms_xmldom-to-create-xml-from-pl-sql/)

 

I need to add this Custom XML to an application_message.

I have these two procedures to help me.

application_message_api.New__ and message_body_api.New__

 

First I use application_message_api.New__ to create a new message.

It returns the error “Message '100000000000002' has no body”

So I use

I run your code from “How to use DBMS_XMLDOM to create XML from PL SQL” to get a CLOB element to use in the body.

Then I use message_body_api.New__ to create the body for the message adding th CLOB element.

 

But, the new body has no CLOB data, and the application message gives the same error: “….

has no body”

I’m doing this wron obviously, and I not even started adding the file.

I hope you can guide me a bit further.

 


Hi @krestensb ,

 

Nice to hear my blog was useful for your requirement and thanks for making as a reference.

Correct way to create an application message is using plsqlap_server_api and there are several methods available to use in different types of outbound integrations.

 plsqlap_server_api.create_application_message__ is a generic method available in this package and following code segment will be useful to create XML using XMLDOM and create application message using this method.

 

DECLARE
L_XMLTYPE XMLTYPE;
L_DOMDOC DBMS_XMLDOM.DOMDOCUMENT;
L_ROOT_NODE DBMS_XMLDOM.DOMNODE;
message_id NUMBER;
record_ plsqlap_record_api.type_record_;

BEGIN
--Create an empty XML document
L_DOMDOC := DBMS_XMLDOM.NEWDOMDOCUMENT;
--XML declaration
dbms_xmldom.setVersion(L_DOMDOC, '1.0" encoding="UTF-8');
dbms_xmldom.setCharset(L_DOMDOC,'UTF-8');

-- Create a root node
L_ROOT_NODE := DBMS_XMLDOM.MAKENODE (L_DOMDOC);

L_XMLTYPE := DBMS_XMLDOM.GETXMLTYPE (L_DOMDOC);
DBMS_XMLDOM.FREEDOCUMENT (L_DOMDOC);
DBMS_OUTPUT.PUT_LINE (L_XMLTYPE.GETCLOBVAL);
plsqlap_server_api.create_application_message__(message_id_ => message_id,
record_ => record_,
sender_ => 'IFS',
receiver_ => 'RECEIVER_NAME',
media_code_ => 'EVENT_BIZAPI',
bizapi_name_ => 'MESSAGE_FUNCTION',
subject_ => 'Message Subject',
xml_ => L_XMLTYPE.GETCLOBVAL);
END;

 


This i good code. Thanks!

Your blog is interesting reading every time.

I remember you promissed a blogpost  about creating Java_Class transformers in IFS someday. Is that day comming up anytime soon?


This i good code. Thanks!

Your blog is interesting reading every time.

I remember you promissed a blogpost  about creating Java_Class transformers in IFS someday. Is that day comming up anytime soon?

It was long due for a new blog post. I’ll make sure this comes pretty soon :sunglasses:


This i good code. Thanks!

Your blog is interesting reading every time.

I remember you promissed a blogpost  about creating Java_Class transformers in IFS someday. Is that day comming up anytime soon?

It was long due for a new blog post. I’ll make sure this comes pretty soon :sunglasses:

Hi @krestensb ,

Hope this is what you were looking for https://dsj23.me/2020/09/07/working-with-java-transformers-in-ifs/

 


@krestensb Were you able to attach a document to an Application Message?
I’m also trying to attach documents to an application message which comes from a Print Dialog Box.
Is it possible to share your code?

 

Thank you in Advance!


Reply