web stats
Mirth Community - View Single Post - How to handle an ACK from an HTTP POST using the HTTP Sender?
View Single Post
Old 04-11-2017, 09:33 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
Join Date: Oct 2010
Posts: 7,125
narupley is on a distinguished road

Since you've cross-posted on both here and SO, I'll just copy my answer from there.

The short answer is that it's completely up to you... Mirth Connect can accommodate any response (or lack thereof) and perform custom user-logic to decide whether the response is "successful" or not.

You could have your external web service generate an HL7 v2.x ACK and send that back. Then on the HTTP Sender side, make sure your Response data types are set to HL7 v2.x, and enable "Validate Response" in the destination settings.

You can also have your web service generate a completely custom response and do custom validation on the MC side. For example if you have your web service send back a response like this:

    "success": true,
    "message": "Message received successfully."
Then you can set your Response data types to JSON, and do this in the response transformer:

if (msg.success !== true) {
    responseStatus = ERROR;
responseStatusMessage = msg.message;
You can also validate purely on the response status code. By default with an HTTP Sender, the message status will be set to SENT only if the HTTP request returned with a status of < 400. Anything else and the status will be left as QUEUED (or ERROR if queuing is disabled).

You can override that behavior in the response transformer though. Maybe you only want it to be SENT if the status is specifically 200 (and not other 2xx or 3xx codes). Set your Response data types to Raw (so that the response transformer will execute even when there is no response), and do this in the response transformer:

var responseStatusLine = $('responseStatusLine');
var responseCode = parseInt(responseStatusLine.split(' ')[1], 10);
if (responseCode != 200) {
    responseStatus = ERROR;
    responseStatusMessage = responseStatusLine.substr(responseStatusLine.indexOf(' ')).trim();
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
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