Handling Inbound Synchronous Transactions
Implement the OnRequest method in the PS_PT application package, in the Integration subpackage, to handle inbound synchronous transactions. All the examples in this section are assumed to be implementations of the OnRequest method.
Message Class Inbound Synchronous Example
The following example implements both the OnRequest method and the OnError method
import PS_PT:Integration:IRequestHandler;
class RequestMan implements PS_PT:Integration:IRequestHandler
method RequestMan();
method OnRequest(&MSG As Message) Returns Message;
method OnError(&MSG As Message) Returns string;
end-class;
/* constructor */
method RequestMan
%Super = create PS_PT:Integration:IRequestHandler();
end-method;
method OnRequest
/+ &MSG as Message +/
/+ Returns Message +/
Local Message &response;
&response = CreateMessage(Operation.SYNC_REMOTE,
%IntBroker_Response);
&response.GetRowset().GetRow(1).GetRecord(Record.QE_FLIGHTDATA).
GetField (Field.DESCRLONG).Value = &MSG.GenXMLString();
Return &response;
end-method;
method OnError
/+ &MSG as Message +/
/+ Returns String +/
/+ Extends/implements PS_PT:Integration:IRequestHandler.OnError +/
Local integer &nMsgNumber, &nMsgSetNumber;
Local string &sText;
&nMsgNumber = &MSG.IBException.MessageNumber;
&nMsgSetNumber = &MSG.IBException.MessageSetNumber;
rem &sText = &exception.DefaultText;
&sText = &MSG.IBException.ToString();
/* ADD SPECIFIC ERROR INFO HERE */
Return &sText;
end-method;
XmlDoc Class Inbound Synchronous Example
The following example uses the GetXmlDoc method:
Local XmlDoc &xmlRequestDoc;
Local XmlDoc &xmlResponseDoc;
Local XmlNode &select;
Local Message &Return_MSG;
Local array of XmlNode &whereClause;
Local string &recordName;
Local string &fieldName;
Local string &fieldValue;
Local Rowset &outputRowset;
Local boolean &return_bool_value;
&xmlRequestDoc = &MSG.GetXmlDoc();
&select = &xmlRequestDoc.DocumentElement;
&recordName = &select.GetAttributeValue("record");
&outputRowset = CreateRowset(@("Record." | &recordName));
&whereClause = &select.GetElementsByTagName("where");
If &whereClause <> Null And
&whereClause.Len <> 0 Then
&fieldName = &whereClause.Get(1).GetAttributeValue("field");
&fieldValue = &whereClause.Get(1).GetAttributeValue("value");
&outputRowset.Fill("WHERE " | &fieldName | "= :1", &fieldValue);
Else
&outputRowset.Fill();
End-If;
&Return_MSG = CreateMessage(OPERATION.EXAMPLE, %Int⇒
Broker_Response);
&xmlResponseDoc = &Return_MSG.GetXmlDoc();
&b = &xmlResponseDoc.CopyRowset(&outputRowset);
Return &Return_MSG;
SoapDoc Class Inbound Synchronous Example
The following example uses the GetXmlDoc method.
Note:
Because GetXmlDoc returns an XmlDoc object, you must receive the inbound request message as an XmlDoc object, then convert it to a SoapDoc object to process it with SOAP methods.
Local XmlDoc &request, &response;
Local string &strXml;
Local SoapDocs &soapReq, &soapRes;
Local Message &Response_Message;
&soapReq = CreateSoapDoc();
&request = &MSG.GetXmlDoc();
&soapReq.XmlDoc = &request;
&OK = &soapReq.ValidateSoapDoc();
&parmN = &soapReq.GetParmName(1);
&parmV = &soapReq.GetParmValue(1);
&Response_Message = CreateMessage(OPERATION.SoapExample,
%IntBroker_Response);
&response = &Response_Message.GetXmlDoc();
&soapRes = CreateSoapDoc();
&soapRes.AddEnvelope(0);
&soapRes.AddBody();
&soapRes.AddMethod("StockPrice", 1);
&soapRes.AddParm(&parmN, &parmV);
&soapRes.AddParm("Price", "29");
&OK = &soapRes.ValidateSoapDoc();
&response = &soapRes.XmlDoc;
Return &Response_Message;