Application Integration Framework – download messages from log

I had to verify inbound messages but there where to many messages to go thru. So i decided to download them all and search thru them all via Notepad++.

Below code will download XML messages from the AIF log and save them on disk.

static void saveAifXmlBasedOnQuery(Args _args)

 date dt;
 utcDateTime utcDT;
 int timeOfday;

 str fileName, filePath;
 XmlDocument xmlDocument;
 AifMessageLog aifMessageLog;
 AifDocumentLog aifDocumentLog;
 AifXmlViewer aifXmlViewer;
 boolean xmlIsValid;

 filePath = @"c:\temp\";

 dt = today();
 timeOfday = str2time("00:00");
 utcDT = datetimeutil::newDateTime(dT,timeOfday);

while select aifMessageLog
 join aifDocumentLog
 where aifMessageLog.MessageId == aifDocumentLog.MessageId
 && aifMessageLog.Company == "<DATAAREAID>"
 && aifMessageLog.ActionId == @"<SERVICE.ACTION>"
 && aifMessageLog.PortName == @"<SERVICE>"
 && aifMessageLog.createdDateTime >= utcDT
 fileName = strFmt("%1.%2", guid2str(aifDocumentLog.MessageId),"xml");

aifXmlViewer = AifXmlViewer::construct(aifDocumentLog.DocumentXml, AifXmlType::XML, guid2str(aifDocumentLog.MessageId));

if (aifDocumentLog.DocumentXml)
 xmlDocument = new XmlDocument();
 xmlIsValid = true;
 xmlIsValid = false;

if (aifXmlViewer.parmEncoding() == #Base64Encoding)
 AifUtil::saveBase64ToFile(filename, aifDocumentLog.DocumentXml);
 else if (xmlIsValid){
 AifUtil::saveXmlToFileOnClient(filePath+fileName, aifDocumentLog.DocumentXml, aifXmlViewer.parmEndpointId());
 AifUtil::saveTextToFile(filename, aifDocumentLog.DocumentXml, aifXmlViewer.parmEncoding());


Leave a Reply