Web Service Sender and Listener in Mirth

Mirth Connect Version : 2.0.1.5164

Here is a short demonstration on implementing Web Services in Mirth.
Based on this tutorial any web service can be implemented in a similar manner.
In order to reduce the complexity and make it a true demo (Yes even you can try your own! – Don’t worry you NEED NOT to write any web service here either in JAVA or .NET); I am using the default web service provided in Mirth.
 
Create two channels in Mirth:
This is organized in below sections:

1. Creating channel WS_Listener
2. Creating channel WS_Sender
3. Running the application
4. Important note

============== 1. Creating channel WS_Listener ==============
Create a new channel name as “WS_Listener”.

———— Source: ————
Source -> Connector Type -> Web Service Listener
Listener Address : “Listen on all interfaces”
Port: 8082 (You can have any port – that must be free for your Operating System)
Web Service : “Default service”
Service Name: Mirth (By Default it should appear)
WSDL URL: http://localhost:8082/services/Mirth?wsdl ( By default)
Method: String acceptMessage(String message) (By default)
Respond from: None
Basic Authentication : Leave empty as of now.

————  Destination: ————
Create a new destination.
Connector Type : Channel Writer
Channel Name : None
Template : ${message.encodedData}

Save the channel and deploy.
============== 2. Creating channel WS_Sender  ==============
Create a new channel name as “WS_Sender”.

———— Source: ————
Source -> Connector Type -> Channel Reader [You can have your own connector] – So that you can send a sample message “Hello World” from that dashboard.
From left panel select the “Edit Transformer” just to define a very simple message type otherwise by default you need to have a HL7 message to process it.
Click on “Message Template”. From drop down -> Delimited text as data type.
In box – just paste a sample text message -> just|a|test|message
In the outbound message template you can set the same.
Data Type – Delimited Text
In Box – just|a|test|message
Respond from : None

————  Destination: ————
Create a new destination.
Connector type -> Wes Service Sender [Select From drow down]
WSDL URL : http://localhost:8082/services/Mirth?wsdl
Click on “Get Operations” button. -> This should fill up several key-values automatically [Service, Port]
Authentication -> As of now select No as radio button.
Send Response to : None. [Select it from drop down; if you want to send to other channel]
Use Persistent Queues : No as radio button
Invocation Type : Two-Way as radio button
Operation : acceptMessage (This is the only operation defined under default Mirth’s web service).
Click on Generate Envelope – You can find a XML i.e SOAP Envelope
Look for the line:
    <!–Optional:–>
      <arg0>SCHOOLHOOD – Learn To Enjoy.</arg0>
Use MTOM – No as radio button
Save this channel and deploy it.
============== 3. Running the application ==============
 From the deployed dashboard, double click on “WS_Sender” app.
 From left panel select “Send Message”.
 Type in the pop up text box -> just|a|test|message
 And press the “Process Message” button.
 
 Come back to the dashboard list.
 Now double click on “WS_Listener” app.
 Check the message details. You should be able to see the string[SCHOOLHOOD – Learn To Enjoy.] passed by you in SOAP envelope under Raw Message tab.

 ============== 4. Important Note  ==============
 1. Only after deploying WS_Listener channel ; the WSDL url becomes active
 http://localhost:8082/services/Mirth?wsdl
 You can try out it on normal IE, Mozilla or any browser
 
 2. In the SOAP envelope, you can use any transformed values passed either from java script or through any processing lagic
 <arg0>SCHOOLHOOD – Learn To Enjoy.</arg0>
 this can take a shape of
 <arg0>${myVariable}</arg0>

Live Situation #4: Explore long path folder with just one click

Working either with Biztalk or Mirth, you are required to remember the path for dropping a file to receive port(location) or viewing the output file to send port. You get frustrated every time to browse such a long path.
This utility will allow you to browse such folders using just single click.

Here is the damn shortcut using DOS command in a batch file.
START” command runs the service into a separate window.
In the code below, define all your receive folders under Option sections dedicating them to specific numbers.

Save this file in your desktop using .bat extension. Just double click on the batch file. Rest will guide you automatically.


@ECHO OFF

:menuLOOP
echo.================== Menu ==================
echo. 1. App1 DropBox  2. App2 DropBox  0. Clear Screen
set myChoice=
echo.&set /p myChoice=Enter a choice number or press ENTER to quit: || GOTO:EOF
echo.&call:Option_%myChoice%
GOTO:menuLOOP

:Option_1   Open App1 DropBox
START C://MyApp1/
cls
GOTO:EOF

:Option_2   Open App2 DropBox
START C://MyApp2/
cls
GOTO:EOF

:Option_0   Clear Screen
cls
GOTO:EOF