A reliable way to post Navision Errors from your webservice without using the event viewer (only the response queue)

For those not knowing here it goes:

Until very recently I did not know a way to post a Navision error message in a reliable way. I the past I developed a way to read the Event Viewer through my webservices. The only question was the reliability of this information. In that scenario, when multiple users invoke the webservice at the same time things can go wrong since the only thing that was being done was the reading of the last warning message from event viewer… So the other day I was performing some tests and, by chance I forgot to remove a testing error.

Something like: ERROR(‘Passed here’).

At the same time I was posting the message from the outer queue in the webservice, the one used from Navision to respond the inner queue. This was being done through a C# webservice as follows:

messageToSend.ResponseQueue = fromNavision;

toNavision.Send(messageToSend, “Navision MSMQ-BA”);

correlationGuid = messageToSend.Id;

Message msqueue = fromNavision.ReceiveByCorrelationId(correlationGuid,new TimeSpan(0,0,0,timeout,0));

msqueue.Formatter = new XmlMessageFormatter(new Type[ { typeof(XmlDocument) });

XmlDocument responseXML = (XmlDocument)msqueue.Body;

try{…}

catch

{

responseXML.OuterXml; //string property from XML and returns all xml in this format

}

…and as result I got the follwoing xml within one of the nodes I prepared to receive the exception descriptions. in this case:



Passed here




So this means it is as simple as it gets. NAS posts the error messages to the response queues. Now the only thing left to do is to get the nodes you need from the standard Navision Error Message. At least it worked with Navision 3.70 b. Hope it helps

I would like to thank everyone contributing in these Forums and my coleagues. They have helped me a lot so here goes my small contribution.

Cheers,
Pedro Pelicano