web stats
Question from a novice user: how to call and orchestrate external Web Services? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-10-2013, 01:08 PM
dzilberman dzilberman is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Location: San Francisco, CA
Posts: 71
dzilberman is on a distinguished road
Default Question from a novice user: how to call and orchestrate external Web Services?

Hello, Mirth Community! I am new to the platform (and medical/EHR integration space as well) but like it a lot so far. I have a very basic question regarding MirthConnect's capabilities to implement "channels" that perform more or less "standard SOA integration" task. For example, I need to get some custom formatted XML as a channel input, extract some fields from that XML, call one external Web service passing these extracted values in a SOAP message body, get a response, Base 64 decode the <XMLresponse> node contents and call a second external Web Service with results from the first SOAP response and get second SOAP response, then parse some output values and write them to a local DB schema.

I have looked at the Mirth Administrator an noticed that there is a "Web Service Listener" to call Web Services - but it looks like it will only call "local" Mirth Web Services, not an external one (for which I need to specify WSL). I noticed also that there is a Database Writer connector for writing out data to DB and some utilities for Base 64 encoding and decoding (JavaScript FileUtil.encode(data)) - but I am not sure how to use them.

Is there any example of MirthChannel calling an external SOAP Web Service, processing (parsing) its response, formatting data and writing it out to a locally running DB (I have mySQL, but any JDBC friendly example will do). I know that you have very extensive JavaScript support in the platform - but is there any "visual development" environment where I could connect such Web Service calls into a "workflow", at least mentally ()?

Many thanks in advance,
Reply With Quote
  #2  
Old 10-10-2013, 02:30 PM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

You're probably thinking of the Web Service Sender (used to invoke remote web services), not the Listener (used to stand up your own SOAP endpoint).

Yep, this sort of workflow is exactly what Mirth Connect is built for... you can even do all of that in one channel. Set your source connector to whatever is appropriate, and your data types to XML.

Your first destination would be a Web Service Sender, and would have a transformer that extracts values from the incoming XML message (you can do that via drag-and-drop) and places them in the connector map. Then you can drag those variables over to the SOAP envelope in the destination settings.

Your second destination would also be a Web Service Sender, and it would have a transformer that grabs the response from the previous destination (also available via drag-and-drop), extracts the "XMLresponse" node, Base64 encodes it, and places it in the connector map. Then again, you can drag that variable to the SOAP envelope to dispatch to the second web service.

Your third destination would be a Database Writer, with a transformer that again grabs the response from the previous destination, extracts whatever data you want, and places values in the connector map. Then on the destination settings, after entering in your DB connection information, you can hit the "Insert" button to pop-up a helpful dialog to build an INSERT SQL statement. Tweak the statement as you see fit, and drag over map variables into the statement (for example, "INSERT INTO table1 VALUES(${col1}, ${col2})").

Also, this may be helpful: http://www.mirthcorp.com/webinars/mi...ect-screencast
__________________
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
  #3  
Old 10-10-2013, 03:00 PM
dzilberman dzilberman is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Location: San Francisco, CA
Posts: 71
dzilberman is on a distinguished road
Default

Thanks very much "Naruplpey" - I'll start with the MirthConnect screen cast hoping to hear/see a similar channel concept. I guess what I am missing is a visual "workflow like" implementation of these outbound Web Service calls that other commercial, heavy tools (Like Oracle SOA etc.) usually offer
But your platform is efficient, lightweight and free (hope it will stay that) - so I'm more willing to learn the ropes for those benefits.
Do you allow users posting exported channel definitions for "code review" - should I need one? Thanks again...
Reply With Quote
  #4  
Old 10-27-2013, 10:16 AM
dzilberman dzilberman is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Location: San Francisco, CA
Posts: 71
dzilberman is on a distinguished road
Default

Quote:
Originally Posted by narupley View Post
You're probably thinking of the Web Service Sender (used to invoke remote web services), not the Listener (used to stand up your own SOAP endpoint).

Yep, this sort of workflow is exactly what Mirth Connect is built for... you can even do all of that in one channel. Set your source connector to whatever is appropriate, and your data types to XML.

Your first destination would be a Web Service Sender, and would have a transformer that extracts values from the incoming XML message (you can do that via drag-and-drop) and places them in the connector map. Then you can drag those variables over to the SOAP envelope in the destination settings.

Your second destination would also be a Web Service Sender, and it would have a transformer that grabs the response from the previous destination (also available via drag-and-drop), extracts the "XMLresponse" node, Base64 encodes it, and places it in the connector map. Then again, you can drag that variable to the SOAP envelope to dispatch to the second web service.

Your third destination would be a Database Writer, with a transformer that again grabs the response from the previous destination, extracts whatever data you want, and places values in the connector map. Then on the destination settings, after entering in your DB connection information, you can hit the "Insert" button to pop-up a helpful dialog to build an INSERT SQL statement. Tweak the statement as you see fit, and drag over map variables into the statement (for example, "INSERT INTO table1 VALUES(${col1}, ${col2})").

Also, this may be helpful: http://www.mirthcorp.com/webinars/mi...ect-screencast
Are there any posted examples of such channels that take XML as an input, then Base 64 encode a part of it and place it into SOAP request payload like:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="https://secure.newcropaccounts.com/V7/webservices">

<soap:Header/>

<soap:Body>

<web:GetPBMEligibilityV3>
..................
<web:xmlIn>base64:PD94bWwgdmVyc2lvbj0iMS4wIj8+DQo8 TkNTY3JpcHQgeG1sbnM6eHNkPSJodHRwOi8vd3d3LnczLm9yZy 8yMDAxL ...

and then Base 64 decode the SOAP response received back that can look like this:

<Message/>
<XmlResponse>PE5ld0RhdGFTZXQ+DQogIDxUYWJsZT4NCiAgI CA8RHJ1Z0hpc3RvcnlUcmFuc2FjdGlvbkd1aWQ+ODI5ZjEyOWY t.......

I am struggling with implementation of recommedation above:

" use Web Service Sender, and it would have a transformer that grabs the response from the previous destination (also available via drag-and-drop), extracts the "XMLresponse" node, Base64 encodes it, and places it in the connector map. "

Any posted examples that I could review will be appreciated.

thanks,
Dan
Reply With Quote
  #5  
Old 11-11-2013, 10:37 PM
dzilberman dzilberman is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Location: San Francisco, CA
Posts: 71
dzilberman is on a distinguished road
Exclamation Why transformer messages fail for Base 64 encoding/decoding?

Hello Mirth Forum,
I have finally got to implement theChannel that calls 2 Web Services with base 64 encoding of a data in SOAP request, passing some parameters form the 1st SOAP response and the decoding of data received in 2nd SOAP response
Please see attached exported channel.

I am getting errors for both Base 64 encode in Destination 1
[2013-11-11 23:26:52,487] ERROR (transformer:?): InternalError: Can't find method com.mirth.connect.server.userutil.FileUtil.encode( string).

and then transform in Destination 2:

com.mirth.connect.donkey.server.channel.components .ResponseTransformerException: CHANNEL:
Test Web Services 1CONNECTOR:
Destination 1SCRIPT SOURCE:
responseSOURCE CODE:

9: }20: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPac kage().getName() + ')');21: }22: }23: function doScript() {24: msg = new XML(connectorMessage.getResponseTransformedData()) ;25: if (msg.namespace('') != undefined) { default xml namespace = msg.namespace(''); } else { default xml namespace = ''; }26: function doTransform() {27: 28: LINE NUMBER:
24DETAILS:
TypeError: The prefix "soap" for element "soap:Envelope" is not bound.

--------------------------------------------------------------------------
I have UNCHECKED "Strip Namespaces" form Data types - should I check them on to make sense of prefix soap: ? How to debug that error and get the channel to work?

Same Web Services SOAP calls via SOAP UI performed manually with manual Base 64 encoding - decoding work fine. So, Mirth Should be able to automate it

Thanks,
Dan Z

Attached Files
File Type: xml Test Web Services 1_Mirth_Errors1.xml (183.5 KB, 29 views)
Reply With Quote
  #6  
Old 11-12-2013, 07:59 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

FileUtil.encode takes in a byte array, not a string. So if you have a string, the bytes of which you wish to encode into Base64, you can do that with FileUtil.encode(new java.lang.String('yourString').getBytes('charsetGo esHere')).

Regarding the transformer exception, it's because the msg['soap:Body'] construct is incorrect (unfortunately namespaces don't quite work for dragging and dropping). Instead, you will have to define your namespace and use it; the E4X syntax is node.namespace::child. More info can be found here, and there are many examples of that on these forums.
__________________
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
  #7  
Old 01-28-2014, 04:11 PM
dzilberman dzilberman is offline
OBX.2 Kenobi
 
Join Date: Sep 2013
Location: San Francisco, CA
Posts: 71
dzilberman is on a distinguished road
Default

Hello again and please excuse the stupidity of the question below - but I cannot figure out why is this happening:

I have a relatively simple channel that takes an input of X12 file (request for Eligibility insurance form 270), applies a Transformer to some of its elements in Destination one and puts values into Connector map variables.

First destination (FileWriter) it works just fine:

URI: /tmp/testWriteEligibility1.txt

[CONTENT]
<test>
<data>
This is a test writing of a file
Date: 2014-1-27 23.56.0
GS01: <GS.01><GS.01.1>HC</GS.01.1></GS.01>
ST01: 837
BHT01: 0019
</data>
</test>


BUT other destinations - which are 2 DBWriters fail to map very same values into VALUES (..) section of INSERT statement and send '?' instead:

Code has this:

Quote:
INSERT INTO ELIGIBILITY_RESPONSE (response_id, response_description, response_status, response_vendor_id, response_create_date, response_modify_date)
VALUES (6,'${BHT01}','A',12,NOW(),NOW())
But in reality even though BHT01= '9370' I am seeing the following in the message:

URL: jdbc:mysql://172.31.32.10:3306/jakaridb_int
USERNAME: jakari_int

[QUERY]
URL: jdbc:mysql://172.31.32.10:3306/jakaridb_int
USERNAME: jakari_int

[QUERY]
INSERT INTO ELIGIBILITY_RESPONSE (response_id, response_description, response_status, response_vendor_id, response_create_date, response_modify_date)
VALUES (6,'?','A',12,NOW(),NOW())


[PARAMETERS]
[Ljava.lang.Object;@93eafc

and then the 3rd Destination fails too even though its actual parameters seem fine

INSERT INTO ELIGIBILITY_VERIFICATION (verification_id, response_id, insurance_id, eligibility_check_date, copay, deductible, deductiblemet, create_date)
VALUES (4,6,716999, NOW(),50.0,250.0,'Y',NOW())


likely b/c previous Destination didn't create a record with response_id

What am I doing wrong - why the Connector map variable value is not getting passed into SQL statement as ${BHT01}' even though it is String value?
Also, can DBWriter run wo queries - one INSERT and then one SELECT that retrieves newly created record ID?

Sorry for asking such a stupid question

thanks
Dan
Attached Files
File Type: xml Test Write Eligibility Var Problem.xml (43.5 KB, 14 views)
Reply With Quote
Reply

Tags
mirthconnect, parsing soap response, soap web services

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 10:23 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation