SingleInstance Codeunit1---------------------------------------------- * OnRun CLEAR(SonicMQRegVBL); IF NOT CREATE(SonicMQRegVBL,TRUE) THEN ERROR('RegVBL: Communication component not created'); recSetup.GET; SonicMQRegVBL.broker:= recSetup."RegVBL Sonic broker"; SonicMQRegVBL.sendQueue:= recSetup."RegVBL send queue"; SonicMQRegVBL.receiveQueue:=recSetup."RegVBL receive queue"; SonicMQRegVBL.pwd:= recSetup."RegVBL password"; SonicMQRegVBL.uid:=recSetup."RegVBL user"; SonicMQRegVBL.messageTimeToLive:=0; SonicMQRegVBL.dbgIncomingMessagePath:=recSetup."RegVBL debug inc. msg. path"; SonicMQRegVBL.Connect; * SendXMLMsgRegVBL(VAR XMLDoc : Automation "'Microsoft XML, version 2.0'.DOMDocument";VAR XMLPropertiesDoc : Automation "'Microsoft XML..) SonicMQRegVBL.SendXmlMessage2(XMLDoc, XMLPropertiesDoc, 0, CorrID); * SonicMQRegVBL::OnXmlMsg(xmlDocument : Automation "''.IDISPATCH";xmlProps : Automation "''.IDISPATCH") codRegVBL.ParseXML(xmlDocument, SonicMQRegVBL.MessageId); Codeunit2 ------------------------------------------------------------------------ ParseXML(varVar : Variant;MsgID : Text[1024]) GlobErrCode :=''; GlobErrText :=''; GlobVBKBID :=''; CLEAR(Cont); IF NOT ISCLEAR(xmldomdocument) THEN CLEAR(xmldomdocument); IF NOT ISCLEAR(XMLResp) THEN CLEAR(XMLResp); CREATE(xmldomdocument); CREATE(XMLResp); xmldomdocument.load(varVar); xmldomdocument.setProperty('SelectionLanguage','XPath'); searchString := 'xmlns:cst=''http://www.company.com/crm/customers'''; tmpVariant := searchString; xmldomdocument.setProperty('SelectionNamespaces',tmpVariant); MessageID := MsgID; s:='cst:RegisterVBL/cst:CustomerInfo'; pxmlroot:=xmldomdocument.selectSingleNode(s); {...Some parsing goes here...} ExtractCustInfoToBufferRegVBL(tmpSMQGetCustomerInfo, tmpContactAltAddress, tmpAkc, WorkMode, Cont."Dok. tipas", VarDocumentID, GlobVBKBID); IF GlobErrCode <> '' THEN BEGIN IF recSMQGetCustomerInfo.GET(tmpSMQGetCustomerInfo.EntryNo) THEN recSMQGetCustomerInfo.DELETE; MakeRegVBLErrXMLDoc(XMLResp,GlobErrCode,GlobErrText,GlobVBKBID); codADASComm.SendXMLMsgRegVBL(XMLResp, XMLPropertiesDoc, MessageID); IF NOT ISCLEAR(xmldomdocument) THEN CLEAR(xmldomdocument); IF NOT ISCLEAR(XMLResp) THEN CLEAR(XMLResp); EXIT; END; {...Some more parsing goes here..} IF GlobErrCode = '' THEN BEGIN MakeRegVBLRespXMLDoc(XMLResp, GlobVBKBID, Cont."No."); codADASComm.SendXMLMsgRegVBL(XMLResp, XMLPropertiesDoc, MessageID); END; IF NOT ISCLEAR(xmldomdocument) THEN CLEAR(xmldomdocument); IF NOT ISCLEAR(XMLResp) THEN CLEAR(XMLResp); {End OF Proc.}
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
There are a lot of XMLDoc and XMLNode objects involved in codeunit2 (parsing),
interesing is what i wrote above, that for ex. in begining of the procedure
It can make xml and send it, but at the end of procedure it can't, seems like program
does not reaches end of procedure and hangs... like some buffer overrun occurs..
](*,)
Thomas
No NAS yet.. do You think it will behave differently with NAS?
Any ideas?
Thanks,
hxr
No, in fact I would prefer to develop this way first. If possible try to strip of code blocks step by step to find out what exactly is the "bad" code.
Thomas
Interesting is that, at least once everything works fine, even in this place,
program can parse and send back xml response, but hangs on second try...
I'll try to rewrite this nextSibling loop with NodeList object, but i'm not sure..
My parsing (codeunit2) works fine without SonicMQ transport DLL.
I have used Timer to check folder each 2 seconds for new XML file,
parse it and save response xml to same folder. Everything worked good.
Program successfully parsed 120 files and no hang up.
The same situation with SonicMQ Transport DLL. It works fine without
Navision. (Navision starts dll, but does not receive OnXmlMsg event and
does not parse) So, DLL receives xml message and send response xml message back to
SonicMQ, tried 100 transactions.
But together they work unpredictable.. May be some kind of memory
overrun occurs and Navision stops receiving OnXmlMsg event or even
closes without any errors displayed.
Actually i have seen few times C++ Run-Time error buffer overrun,
finsql.exe.. must be terminated, but usually Navision just stops receiving XML
(but works other forms and etc...)
Mystigue..maybe SonicMQ Transport DLL needs to be modified to clear some kind
of memory after each transaction or sth. like that, if it's possible..
hxr
Thomas
and in my company there is no SonicMQ
I use Microsoft XML v. 6.0, SonicMQ uses XML 2.0 i think,
but actually OnXmlMsg event receives .IDispatch, which i take as Variant
and later load to my XML 6.0 document object, which i parse, code is below:
ParseXML(myVar : Variant; MsgID : Text[1024])
IF NOT ISCLEAR(xmldomdocument) THEN CLEAR(xmldomdocument);
CREATE(xmldomdocument);
xmldomdocument.load(myVar);
:-k may be i can try to load incoming xml as XML version 2.0 object,
or even take it not by value, but by reference..
hxr