web stats
Mirth Channel to move xml - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2019, 04:57 AM
mrobz mrobz is offline
Mirth Newb
 
Join Date: Apr 2016
Location: Brighton, UK
Posts: 11
mrobz is on a distinguished road
Default Mirth Channel to move xml

Hi Guys

OK so I have a mirth channel that I want to monitor a folder, pick up XML, read a field, create a folder named after the content of that field, and then move the XML to it. I have a source transformer to read the data into a variable called DeviceID which I then use for the folder to write to.

It's all working except the file I end up with is a junk 151Kb file

Channel
https://www.dropbox.com/s/6vwctav5tq...E_XML.xml?dl=0

Sample XML file
https://www.dropbox.com/s/sriqzg61z1...25041.xml?dl=0

Probably something simple?

Thanks!

Matthew
Reply With Quote
  #2  
Old 11-22-2019, 05:21 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 250
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Your destination File Type is set to binary. XML is text. Update that. You may also want to update your Template to be: ${XmlUtil.prettyPrint(${message.rawData})} so the XML is formatted properly on the other side.
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #3  
Old 11-22-2019, 05:28 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,059
agermano is on a distinguished road
Default

I didn't actually load your channel, but looking at the xml, don't use an outbound template in your transformer if you want the message to pass through. When you use an outbound template that is the starting point for your outbound message and you have to apply any changes to the variable tmp instead of msg.

You also will probably want to turn off "strip namespaces" from your xml datatype options if you intend to keep the namespaces present in the inbound message. That will probably change how you access your DEVICEID.

In your destination templates, it's generally good practice to use ${message.encodedData} instead of ${message.rawData}. rawData is your message at the start of the destination transformer, and encodedData is your message after transformations. If your transformer doesn't alter the message, both values will be the same.

Edit: Jack posted while I was composing, but that is also good advice.
Reply With Quote
  #4  
Old 11-22-2019, 05:32 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 250
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

I didn't even catch the Outgoing Template... thanks agermano. That could be why the formatting was ugly, but I stand behind the binary/text setting. "raw" will get your the original file output (provided there is no outbound template) but yes, use encoded if you are going to format/change it at all.
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #5  
Old 11-22-2019, 05:44 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,059
agermano is on a distinguished road
Default

I always use encoded by default, unless I know that I don't want it for a specific reason. You'll run into less issues that way.
Reply With Quote
  #6  
Old 11-22-2019, 07:07 AM
mrobz mrobz is offline
Mirth Newb
 
Join Date: Apr 2016
Location: Brighton, UK
Posts: 11
mrobz is on a distinguished road
Default

Thanks guys will try those suggestions now
The outgoing template is irrelevant and left over from the old channel I started from
I'll get rid of it!
Reply With Quote
  #7  
Old 11-22-2019, 07:18 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 250
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Outbound templates are for very specific purposes and will cause lots of issues. Use them wisely!
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #8  
Old 11-22-2019, 07:26 AM
mrobz mrobz is offline
Mirth Newb
 
Join Date: Apr 2016
Location: Brighton, UK
Posts: 11
mrobz is on a distinguished road
Default

I got rid of the template, the Strip Namespaces checkbox and switched to text and the amended code for the Destination box and...all now working thanks a lot much appreciated!
Reply With Quote
Reply

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 -8. The time now is 03:24 AM.


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