web stats
xml namespace issues with routeMessage when not queued - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-27-2012, 08:53 AM
whmurray whmurray is offline
Mirth Newb
 
Join Date: Feb 2012
Posts: 14
whmurray is on a distinguished road
Default xml namespace issues with routeMessage when not queued

I have channel that reads a file (which happens to be XML/CCD). THen it passed that file using:
var vmResponse = router.routeMessage('ProcessCCD', contents, true);

The second channel ("ProcessCCD") can see the xml ok and I can parse the ccd data content ok.

However, If I change the routeMessage call to pass the last parameter as "false" so no que, The second channel gets the xml, but there seems to be a namespace issue.

Questions:
1) If I call a channel using routeMessage, and need result data from that channel, then is using the "false" as the last parameter the right thing to do?
2) Why does this change how the second channel sees the xml data?
Reply With Quote
  #2  
Old 04-30-2012, 06:35 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,082
narupley is on a distinguished road
Default

That's interesting... can you post your channels for reference? Also, when you route the messages with and without queues, what is the difference in the raw data received by the second channel?
Reply With Quote
  #3  
Old 05-01-2012, 10:19 AM
whmurray whmurray is offline
Mirth Newb
 
Join Date: Feb 2012
Posts: 14
whmurray is on a distinguished road
Default

The top level channel has a "javaScript writer" destination. The following javaScript is used to read a CCD file and send it to the next channel:

Code:
function ProcessFile(filePath) {
logger.debug(filePath);
	var contents = FileUtil.read(filePath);
	var vmResponse = router.routeMessage('ProcessCCD', contents, false); // cnl name, msg, queue, sync
	var theJsonText = new XML(vmResponse.getMessage()).JSONText;
	var hl7Doc = JSON.parse(theJsonText);
	return hl7Doc;
}
The channel the above calls has and xml template where I extract some fixed parts of the CCD, then go into javaScript to digest it further. It works if the above routeMessage call uses que. However, if it does not, the second channel was failing.

After a lot of debugging (see note below), I "fixed" this by adding an initial javascript step in my second channel to set the namespace as follows:

Code:
default xml namespace = msg.namespace();
I also added the sameline at the beginning of my javaScript destination xfrom (second channel). I also tried with and without the "strip namespaces" option which did not seem to affect results at all.
I know that mirth prepends and postpends some script to my scripts before they are compiled (see below), and there is this line it adds:

Code:
if (msg.namespace("") != undefined) { default xml namespace = msg.namespace(""); } else { default xml namespace = ''; }
All I know is that after I set the default xml namespace in the 2 places mentioned, my "ProcessCCD" channel works the same way regardless of if it is called as queued or not. Also, to answer your question regarding the input data to the second channel, I could not tell any difference in the input data for either queued or non queued. My conclusion is that in the queued path, something is setting the default xml namespace and that is not being done in the non queued path.

Regarding debugging: Having searched the forums, I could only find people suggesting to use the logger for debugging. Kinda of a step back in time I think. I spent 2 days to try to understand if something better is possible and in fact I found it is easy to debug Mirth scripts (single step, breakpoints, context, etc) once you understand the technique. I will post seperately if there is interest and if nobody tells me not to. I has saved me enormous time and provided great insight into what Mirth is doing.
Reply With Quote
  #4  
Old 04-02-2013, 04:04 PM
MikeCaldwell MikeCaldwell is offline
Where are the forums?
 
Join Date: Mar 2008
Location: Sacramento, CA
Posts: 156
MikeCaldwell
Default

** I would love to know that ( debug Mirth scripts )! Please post any info you can on the
(single step, breakpoints, context, etc) , I didn’t even know you could do that.

I also thought I stumbled over the multi commenting, where I could highlight and hit a key and a // was placed in front of the lines, am I thinking of something else?
__________________
Mike Caldwell
Alliance HealthCare - GE VAR
Rocklin, CA
Centricity PM/EMR Support - Developer - Network Engineer
http://MirthPRO.Com
Reply With Quote
  #5  
Old 04-03-2013, 01:01 AM
StefanScholte StefanScholte is offline
 
Join Date: May 2009
Location: Netherlands, Harderwijk
Posts: 285
StefanScholte is on a distinguished road
Default

As Mike Caldwell stated.

I too love to know how to debug without the logger statements.
Reply With Quote
  #6  
Old 04-03-2013, 08:16 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 4,082
narupley is on a distinguished road
Default

We're planning on implementing JavaScript debugging features, but in the meantime you can read up on it here: https://developer.mozilla.org/en-US/...cript_Debugger
__________________
Step 1: JAVA CACHE...DID YOU CLEAR

Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Tags
namespace, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:08 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Mirth Corporation