Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Response from another channel in mirth

We have two channels called channelA and channelB.

In channelA we have two destinations

  • a. first destination will invoke the channelB with XML data as input and get the response from the channelB in XML format.

  • b. retrieve the response of first destination in xml format and process it.

var dest1 = responseMap.get("destination1"); var resMessage = dest1.getMessage();

I am getting channelB response as "Message routed successfully".

How I will get actual XML from channelB instead of "Message routed successfully" message.

We are doing above steps to define generic channels such that we can reuse it in different scenarios in the mirth application.

We using mirth 2.2.1.5861 version.

like image 458
Riyaz shaik Avatar asked Sep 15 '25 15:09

Riyaz shaik


1 Answers

We are doing something very similar to what you described. In our case, destination1 is a SOAP sender (SOAP uses XML for its send and receive envelopes). Here's the syntax we are successfully using in destination2 JavaScript Writer:

var dest1 = responseMap.get("destination1");
var resMessage = dest1.getStatus().toString();

if (resMessage == "SUCCESS")
{
    var stringResponse = dest1.getMessage();
    channelMap.put('stringResponse',stringResponse);

    var xmlResponse = new XML(stringResponse);

    // use e4x notation to parse xmlResponse
}

If your destination1 is not a SOAP sender, then the XML response from channelB might be getting packaged up in some way that you need to extract from "stringResponse." You can see the contents of the channelMap variable "stringResponse" after running the message through the channel. Go to the dashboard, double-click the channel, find a message that has been sent, and then look at the mappings tab. What does the content of "stringResponse" actually look like? Is it just "Message routed successfully?" Or is that text followed by the XML that you're after?

like image 144
csj Avatar answered Sep 18 '25 08:09

csj