Handling Outbound Synchronous Transactions

Use the IntBroker class SyncRequest method for handling outbound synchronous transfers. To send a message synchronously, you can employ SyncRequest in:

  • The record field SavePreChange PeopleCode event.

  • The record field SavePostChange PeopleCode event.

  • The record field Workflow PeopleCode event.

  • The record field FieldChange PeopleCode event.

  • An implementation of the OnRequest method.

  • An implementation of the OnNotify method.

Note:

The OnRequest and OnNotify events are triggered only when an inbound transaction occurs, however, when the receiving PeopleCode runs, it can also send messages.

The response message that is returned from an outbound synchronous transaction is no different from an inbound request message. Once you have it in a Message, XmlDoc, or SoapDoc object, it has the same properties as any other object of that type and can, therefore, be treated exactly the same way.

See Receiving and Processing Messages.

Message Class Outbound Synchronous Example 1

The following example uses the IntBroker class SyncRequest method:

Local Message &MSG, &response;
Local Rowset &SALES_ORDER;
&SALES_ORDER = GetLevel0();
&MSG = CreateMessage(OPERATION.SALES_ORDER_SYNC);
&MSG.CopyRowsetDelta(&SALES_ORDER);
/* send the synchronous request; the return value is the response 
message object */
&response = %IntBroker.SyncRequest(&MSG);
/* check the response status; 0 means OK */
If (&response.ResponseStatus = 0) Then
  /* process the response */
  MY_SALES_ORDER_SYNC.ORDER_ID = &response.GetRowset().GetRow(1)
.GetRecord(Record.SO_RESPONSE).GetField(Field.ORDER_ID).Value);
else
  /* do error handling */
End-If;

Message Class Outbound Synchronous Example 2

The following example shows the use of CopyTo to get the data back from the response and into the component buffer, and therefore the page:

Local Message &msgZipRequest, &msgZipResponse;
Local Rowset &RS, &rsMessageRowset;
&RS = GetLevel0();
&msgZipRequest = CreateMessage(OPERATION.ZIP_REQUEST);
&msgZipRequest.CopyRowset(&RS);
/* send the synchronous request; the return value is the response 
message object */

&msgZipResponse = %IntBroker.SyncRequest(&msgZipRequest,
Node.ZIPTOCITYANDSTATE);

/* check the response status; 0 means OK */
If (&msgZipResponse.ResponseStatus = 0) Then
   /* process the response */
   &rsMessageRowset = &msgZipResponse.GetRowset();
   &rsMessageRowset.CopyTo(&RS);
else
   /* do error handling */
End-If;

XmlDoc Class Outbound Synchronous Example

The following example uses the IntBroker class SyncRequest method:

Local Message &MSG, &RESP_MSG;
Local XmlDoc &flightplan_xmldoc, &xmldocReturn;
Local XmlNode &ac_number, &msi_sensor, &ofp;

&flightplan_xmldoc = CreateXmlDoc("");

&ac_number = &flightplan_xmldoc.CreateDocumentElement("flightplan");

&msi_sensor = &ac_number.AddElement("msi_sensor");
&msi_sensor.NodeValue = "flir";
&ofp = &ac_number.AddElement("ofp");
&ofp.NodeValue = "8.44";

&MSG = CreateMessage(Message.SYNC_REQUEST_EXAMPLE);

&MSG.SetXmlDoc(&flightplan_xmldoc);

&RESP_MSG = &MSG.SyncRequest();

&xmldocReturn = &RESP_MSG.GetXmlDoc();

&return_data = &xmldocReturn.GenXmlString();