web stats
help with response - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2020, 05:43 AM
lunknowl lunknowl is offline
Mirth Newb
 
Join Date: Feb 2020
Posts: 11
lunknowl is on a distinguished road
Default help with response

hi, i try to set up a xml to hl7 data transformation using mirth control
XML TCP --> Mirth --> HL7 TCP

the program is working good but i need to create a custom xml response back to XML TCP
i setup using postprocessor

// This script executes once after a message has been processed
// Responses returned from here will be stored as "Postprocessor" in the response map
var xml_msg = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'+
'<dispenseResponse><isSuccessful>Y</isSuccessful><message>Y</message><deviceResponse>Y</deviceResponse></dispenseResponse>';
var sResp = ResponseFactory.getSentResponse(xml_msg)
responseMap.put('ResponseAck', sResp);

i can see the response on Mirth Control Pane (view message--> response)l but i cant see the response back from XML TCP????

Does Anyone know whats wrong?
Reply With Quote
  #2  
Old 02-19-2020, 07:45 AM
lunknowl lunknowl is offline
Mirth Newb
 
Join Date: Feb 2020
Posts: 11
lunknowl is on a distinguished road
Default

Or how do i create a custom response as soon as i receive data from XML TCP, i response!
thanks
Reply With Quote
  #3  
Old 02-19-2020, 07:54 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,176
agermano is on a distinguished road
Default

You can actually just return xml_msg; and select post-processor as the response in your source tab. You don't need to generate a Response or put it in the responseMap.

I vaguely remember hearing at some point that there was a bug that adding a key to the responseMap in the post-processor didn't include it in the response drop down selection on the source tab. I don't know if that has been resolved in current versions or not.
Reply With Quote
  #4  
Old 02-19-2020, 08:06 AM
lunknowl lunknowl is offline
Mirth Newb
 
Join Date: Feb 2020
Posts: 11
lunknowl is on a distinguished road
Default

Somehow when i send message over tcp, i need to connect-->send--> then disconnect for data got throught
if im not disconnect the data never go through, then i already disconnect, i cant tell is the response work or not (i still see response in mirth control panel)
Reply With Quote
  #5  
Old 02-19-2020, 10:09 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,176
agermano is on a distinguished road
Default

How do you have your TCP listener set up? You need to use framing characters to indicate when one message stops and the next one starts if you don't want to have to disconnect to indicate the end of the message. MLLP is the default transmission mode and defines those characters for you. The defaults should work fine for XML.

Keep in mind that TCP is a stream protocol and is asynchronous. You'll have to read the return messages with the framing characters as well or you won't know when the message is complete. You'll probably need to implement timeouts in case mirth takes too long to respond or something goes wrong.

HTTP would be better suited for something like this as it handles all of that for you.
Reply With Quote
  #6  
Old 02-19-2020, 07:42 PM
lunknowl lunknowl is offline
Mirth Newb
 
Join Date: Feb 2020
Posts: 11
lunknowl is on a distinguished road
Default

Quote:
Originally Posted by agermano View Post
How do you have your TCP listener set up? You need to use framing characters to indicate when one message stops and the next one starts if you don't want to have to disconnect to indicate the end of the message. MLLP is the default transmission mode and defines those characters for you. The defaults should work fine for XML.

Keep in mind that TCP is a stream protocol and is asynchronous. You'll have to read the return messages with the framing characters as well or you won't know when the message is complete. You'll probably need to implement timeouts in case mirth takes too long to respond or something goes wrong.

HTTP would be better suited for something like this as it handles all of that for you.
i use the default tcp listening with simple xml format <xml> data </xml> how can i detect the end of xml message and how can i return a message??? do you have any sample or you just guessing??
Reply With Quote
  #7  
Old 02-20-2020, 04:53 AM
lunknowl lunknowl is offline
Mirth Newb
 
Join Date: Feb 2020
Posts: 11
lunknowl is on a distinguished road
Default

the format of my xml is

<?xml version="1.0" encoding="utf-8"?>
<XML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
message
</XML>


when i change to tcp listener to

<?xml message </XML>

the message become
"
version="1.0" encoding="utf-8"?>
<XML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
message
"

look like the mirth listener remove the <?xml and </XML> from my raw data.
now it not a complete xml anymore??
Reply With Quote
  #8  
Old 02-20-2020, 10:59 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,176
agermano is on a distinguished road
Default

Framing characters are markers that go before and after your message. They get removed as they are not part of the message. A basic TCP stream has no concept of XML data.

As I mentioned before, HTTP will work much better here as it deals with requests and responses rather than bidirectional streams like plain TCP.

If you must send XML to a TCP listener, the easiest way to do that will be using MLLP.

If you must send XML over TCP in a stream without any framing characters, you'll have to write your own XML TransmissionModeProvider (like Basic TCP or MLLP) to handle those streams and split them into messages. This would be much more difficult to implement compared to the other two options.

Last edited by agermano; 02-20-2020 at 12:46 PM.
Reply With Quote
  #9  
Old 02-21-2020, 06:04 AM
lunknowl lunknowl is offline
Mirth Newb
 
Join Date: Feb 2020
Posts: 11
lunknowl is on a distinguished road
Default

Quote:
Originally Posted by agermano View Post
Framing characters are markers that go before and after your message. They get removed as they are not part of the message. A basic TCP stream has no concept of XML data.

As I mentioned before, HTTP will work much better here as it deals with requests and responses rather than bidirectional streams like plain TCP.

If you must send XML to a TCP listener, the easiest way to do that will be using MLLP.

If you must send XML over TCP in a stream without any framing characters, you'll have to write your own XML TransmissionModeProvider (like Basic TCP or MLLP) to handle those streams and split them into messages. This would be much more difficult to implement compared to the other two options.
thanks for support, but i already mention that my xml data send over tcp without framing characters and you keep give me other information that i dont need, i just want to know is there a way to setup xml data over tcp without framing charcter and how to set it up? i can understand the concept but setup up is different problem, thanks anyway
Reply With Quote
  #10  
Old 02-21-2020, 06:50 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,176
agermano is on a distinguished road
Default

My 3rd option that you quoted is what you are asking for. You'll have to develop a custom plugin for mirth to handle it. Out of the box Mirth only supports multiple messages over the same TCP connection when you are using framing characters. I'm pushing other options because those are simple to implement. What you are asking for is much too difficult to answer in a forum post.
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:39 PM.


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