4

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.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Riyaz shaik
  • 41
  • 1
  • 1
  • 2

2 Answers2

2

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?

csj
  • 21,818
  • 2
  • 20
  • 26
  • Thanks for your response. I am getting "stringResponse" as "SUCCESS: Message routed successfully" – Riyaz shaik Jul 04 '13 at 12:08
  • Are you using the Channel Writer / Channel Reader connectors? I don't believe those connectors propagate responses. What are you doing to create your XML response in channel? Mirth won't automate that for you since there's no standard acknowledgement protocol for XML communications. – csj Jul 04 '13 at 19:05
  • Thanks for your response. In our application we have a common functionality which is using by another channels also. So we need to extract that common functionality so that we build a system in a code reuse manner. – Riyaz shaik Jul 09 '13 at 09:58
  • We've had to do much of the same. Most of our common functionality sits in Mirth Javascript code templates, and a little bit resides in a custom Java library that we link to. Since you didn't directly reply to my two questions above, I'm going to assume you're on track. Good luck. – csj Jul 09 '13 at 18:20
1

Create ChannelB having source data type as an XML, and put source as a channel reader. You have to make a single destination on ChannelA as a Channel Writer, and put ChannelB in the details.

This way whatever message you get in the form of an XML in ChannelAwill be routed to ChannelB.

Sid
  • 988
  • 8
  • 27