Tuesday, 5 April 2016

Sending < and > symbols to a Web Service Sender in Mirth

 

I have a Mirth channel interface that receives an HL7 message, and then the values are extracted and passed on to a web service via a Web Service Sender.

Mostly it worked well, but for a few messages I got the following error.

Web Service Sender error
ERROR MESSAGE: Error creating web service dispatch
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(Unknown Source)
    at com.mirth.connect.connectors.ws.WebServiceDispatcher.send(WebServiceDispatcher.java:514)
    at com.mirth.connect.donkey.server.channel.DestinationConnector.handleSend(DestinationConnector.java:738)
    at com.mirth.connect.donkey.server.channel.DestinationConnector.process(DestinationConnector.java:436)
    at com.mirth.connect.donkey.server.channel.DestinationChain.call(DestinationChain.java:155)
    at com.mirth.connect.donkey.server.channel.Channel.process(Channel.java:1653)
    at com.mirth.connect.donkey.server.channel.Channel.dispatchRawMessage(Channel.java:1156)
    at com.mirth.connect.donkey.server.channel.SourceConnector.dispatchRawMessage(SourceConnector.java:192)
    at com.mirth.connect.donkey.server.channel.SourceConnector.dispatchRawMessage(SourceConnector.java:170)
    at com.mirth.connect.connectors.tcp.TcpReceiver$TcpReader.call(TcpReceiver.java:650)
    at com.mirth.connect.connectors.tcp.TcpReceiver$TcpReader.call(TcpReceiver.java:485)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to get header stream in saveChanges:
    ... 15 more
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: SOAP exception while trying to externalize:

If this was failing all the time, it probably means that the Soap’s XML structure has been corrupted while I was adding variables, but as this was only with certain messages I was pretty sure that the data was corrupting the XML structure.

Looking at the Mirth Dashboard, I navigated to the ‘sent message’ and found the culprit

<win:UniversalServiceText>Type < 3</win:UniversalServiceText>

Yep, that would do it. So how do you convert this to:

<win:UniversalServiceText>Type &lt; 3</win:UniversalServiceText>

I’ve always felt that Mirth should do this for you in the transformers, but every time I try to run a Soap message through the transformers I get errors that I just can’t seem to fix. Besides, I’m not even sure that this would work; it doesn’t very well with HL7 messages.

Instead, I’m back to coding the answer again, each variable at a time. So when you create your variable just include the following like so.

msg['OBR']['OBR.4']['OBR.4.2'].toString().replace('<', '&lt;').replace('>', '&gt;')

clip_image002

I’d love to get feedback about how others get around this issue.

1 comment:

  1. This fix worked for me - thanks HL7 Interfacer!

    ReplyDelete