Handling Outbound Asynchronous Message Transmission
To send a message asynchronously, use the IntBroker class Publish method in:
-
A record field PeopleCode event.
-
A component PeopleCode event.
When publishing from a component, publish messages only from the SavePostChange event, using the deferred mode property.
-
An Application Engine program.
-
An implementation of the OnNotify method.
-
An implementation of the OnRequest method .
The OnRequest service operation event is triggered only when an inbound transaction occurs. However, when the receiving PeopleCode runs, the program can also send messages.
Message Class Outbound Asynchronous Example
The following example uses the Publish method in the PeopleCode IntBroker class:
Local Message &MSG;
Local Rowset &SALES_ORDER, &RS;
/*Get a pointer to the component buffer rowset */
&SALES_ORDER = GetLevel0();
/*Create an instance of the SALES_ORDER_ASYNC message object */
&MSG = CreateMessage(OPERATION.SALES_ORDER_ASYNC);
/*Copy the rows from the rowset to the message object */
&MSG.CopyRowset(&SALES_ORDER);
/*Send the message */
%IntBroker.Publish(&MSG);
XmlDoc Class Outbound Asynchronous Example
The following example uses the Publish method:
Local XmlDoc &xmlRequestDoc;
Local Message &MSG;
/*Create an XmlDoc Object */
&xmlRequestDoc = CreateXmlDoc();
/* Parse a URL or input XML file into an XmlDoc */
&bool = &xmlRequestDoc.ParseXmlFrom URL("C:\pt\appserv\files\
input.xml");
/* Populate message with XML data */
&MSG = CreateMessage(OPERATION.XmlRequest);
&MSG.SetXmlDoc(&xmlRequestDoc);
/* Sent request */
%IntBroker.Publish(&MSG);
Identifying SOAP Faults
You can implement the OnAckReceive method to access IBInfo data. This enables you to read the content of acknowledgements returned by recipient systems of asynchronous SOAP messages. The ability to access acknowledgement content is useful when sending SOAP messages, since although there may be no HTTP protocol errors while sending them, SOAP faults may occur.
If the message is nonrowset-based, use the message class GetXmlDoc method to get the response data. This returns an XmlDoc object.
If the message is rowset-based, use the message class GenXMLString method to get the response data. This returns a string object which you can load into an XmlDoc object.
If SOAP faults are found, you can set the status equal to Error so that the errors appear in the Service Operations Monitor for the publication contract.
The following code example shows how to use GetXmlDoc and GenXMLString in an implementation of the OnAckReceive method. Valid status overrides are %Operation_Done, %Operation_Error, and %Operation_Retry:
import PS_PT:Integration:IReceiver;
class AckReceiveHandler implements PS_PT:Integration:IReceiver
method AckReceiveHandler();
method OnAckReceive(&_MSG As Message) Returns integer;
end-class;
/* constructor */
method AckReceiveHandler
end-method;
method OnAckReceive
/+ &_MSG as Message +/
/+ Returns Integer +/
/+ Extends/implements PS_PT:Integration:IReceiver.OnAckReceive +/
/* Variable Declaration */
If &MSG.IsStructure Then
/* if message is rowset-based */
&str = &MSG.GenXMLString();
Else
/* if message is nonrowset-based */
&xmldoc = &MSG.GetXmlDoc();
End-If;
Return (%Operation_Done);
end-method;
You can also implement the OnAckReceive method to read response content data returned from third-party systems when using the HTTP target connector.
Related Topics