0

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)
{
 #File
 #AIF

 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();
 if(xmlDocument)
 if(xmlDocument.loadXml(aifDocumentLog.DocumentXml))
 {
 xmlIsValid = true;
 }
 else{
 xmlIsValid = false;
 }
 }

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

jack

Leave a Reply