Monday, April 11, 2016

HL7 Inbound endpoints - WSO2 ESB 4.9.0

I had to test ESB hl7 inbound endpoints for a project requirement and I will share the steps followed in there.

I'm using HL7 browser tool to validate the hl7 message and send it to the inbound endpoint. You can download the HL7 browser from this link. Download the ZIP file from the site.  I will guide you how to use this tool in later on this post. Now lets go towards the WSO2 ESB and start configuring the hl7 inbound endpoint.

Following is the inbound endpoint configuration. (This inbound endpoint is configured to listen on port 9090)

 <inboundEndpoint name="hl7_inbound" onError="hl7_errseq"  
     protocol="hl7" sequence="hl7_inseq" suspend="false">  
     <parameters>  
       <parameter name="inbound.hl7.ValidateMessage">true</parameter>  
       <parameter name="inbound.hl7.CharSet">UTF-8</parameter>  
       <parameter name="inbound.hl7.BuildInvalidMessages">false</parameter>  
       <parameter name="inbound.hl7.TimeOut">10000</parameter>  
       <parameter name="inbound.hl7.AutoAck">false</parameter>  
       <parameter name="inbound.hl7.PassThroughInvalidMessages">false</parameter>  
       <parameter name="inbound.hl7.Port">9090</parameter>  
     </parameters>  
   </inboundEndpoint>  


hl7_inseq configuration

 <?xml version="1.0" encoding="UTF-8"?>  
 <sequence name="hl7_inseq" onError="hl7_errseq" xmlns="http://ws.apache.org/ns/synapse">  
   <log level="full">  
     <property name="where" value="in hl7_inseq"/>  
   </log>  
   <property name="HL7_APPLICATION_ACK" scope="default" value="true"/>  
   <property name="HL7_RESULT_MODE" scope="default" value="ACK"/>  
   <respond/>  
 </sequence>  

hl7_errseq configuration

 <?xml version="1.0" encoding="UTF-8"?>  
 <sequence name="hl7_errseq" xmlns="http://ws.apache.org/ns/synapse">  
   <log level="custom">  
     <property name="where" value="in hl7_errseq"/>  
   </log>  
   <property name="HL7_RESULT_MODE" scope="default" value="NACK"/>  
   <property name="HL7_NACK_MESSAGE" scope="default" value="internal error"/>  
 </sequence>  



Now we can test the inbound endpoint functionality, but for that we need a valid hl7 message. I have created a valid hl7 message and you can download it from here.

Extract the HL7 browser archived file, go inside to the extracted folder and you can see the lib folder, HL7Browser.jar and README.txt

Open a terminal in this location and execute the below command.

 java -jar "Hl7Browser.jar"   

Then you can see the HL7Browser UI.

Open the hl7 message contained file. (You can use the file which I shared) Remember to click "use Advance HL7 v2 parser".


Click on the green right icon to validate the message.


Using connect utility connect to the Host with inbound endpoint port and send the message. (untick the "send  all" and just send the 1st message). You can see the Ack for the sent message.