Making HL7 BC work with Java EE SE

You can use Java for transformation or routing logic instead of BPEL by using one of the two options. One is using Java EE SE and another is POJO SE. A Java EE SE can work as an EJB and can utilise App.Server's services such as transactions, pooling etc. whereas a POJO SE cannot. A Java EE SE acts as a bridge between Java EE and JBI environment. In this blog entry I will you guide you step by step on how to make HL7 BC to interact with Java EE SE.


Inbound Scenario: In this scenario HL7 BC receives a HL7 message (ADT A43) and invokes Java EE SE. Here, we will create an EJB webservice. We will use a WSDL which uses HL7 Binding instead of SOAP binding to create the webservice.



  1. Create a WSDL with HL7 Binding and have it in some location. In this step we will create a Java application project just to create the WSDL. If the WSDL is already created , you can proceed to to Step 2.

    •  Download the HL7 V2 XSDs from http://wiki.open-esb.java.net/attach/HL7BC/HL7v2XSDs.zip and extract it somewhere.

    • Create a New Java Application Project

    • Create a WSDL by clicking on File -> New File _> WSDL document -> choose Concrete WSDL Document -> Choose Binding as HL7 Binding and Click Next.

    • Choose the Request Message by Clicking on Browse -> Selecting the xsd ADT_A43.xsd and choosing the element ADT_A43.CONTENT.



  2. Create an EJB Module :

    • Go To File -> New Project -> Enterprise -> EJB Module. Click Next.

    • Give a project name . Click Next

    • Choose Server as Glassfish V2 and Java EE Version as Java EE 5.



  3. Create an EJB Webservice from the WSDL created from Step 1.

    • Right Click on the EJB Module and choose - > New -> Other -> Webservices -> WebService from WSDL and click Next.

    • Provide a class name and package name for the ejb class and choose the WSDL created in Step 1. Wait for sometime until Web Service Port appears and Click on Finish



  4. Now, you have an EJB java file with one method hl7WsdlOperation(org.hl7.v2xml.ADTA43CONTENT part1). The class org.hl7.v2xml.ADTA43CONTENT is a JAXB generated class. You can use the methods of this class to access the values from received message. If you want invoke another JBI component from this EJB by passing the received message, See the outbound scenario. Now, for testing purpose you can just print the received "part1" object inside the method.

  5. Create a Composite Application and deploy it.

    • Go To File -> New Project -> Service Oriented Architecture -> Composite Application. 

    • Provide a project name and finish the wizard.

    • Double Click on the Service Assembly to open the CASA editor.

    • Drag and drop the EJB Module into the CASA editor.

    • Build and deploy the Composite Application.




Outbound Scenario: In this scenario, we will read the HL7 message from File using File BC, invoke Java EE SE passing the HL7 message into JAXB object and invoke HL7 BC from JavaEE SE passing the JAXB object.



  1. Create a WSDL with File Binding (which uses hl7encoder-1.0) and have it in some location.

    • Download the HL7 V2 XSDs from http://wiki.open-esb.java.net/attach/HL7BC/HL7v2XSDs.zip and extract it somewhere.

    • Create a Java Application Project

    • Create a WSDL by clicking on File -> New File _> WSDL document -> choose Concrete WSDL Document -> Choose Binding as File Binding, Choose Type as Poll and click next.

    • Provide the file name as input.txt and Click on Finish.

    • Open the WSDL Editor. Go to Messages -> PollInputMessage -> part1 .

    • Change the datatype by right clicking and choosing the element ADT_A43.CONTENT from ADT_A43.xsd

    • Traverse the tree to input -> file:message. In the properties sheet, choose use = encoded and provide encodingStyle as hl7-encoder1.0



  2. Create an EJB Module :

    • Go To File -> New Project -> Enterprise -> EJB Module. Click Next.

    • Give a project name . Click Next

    • Choose Server as Glassfish V2 and Java EE Version as Java EE 5.



  3. Create an EJB Webservice from the WSDL created from Step 1.

    • Right Click on the EJB Module and choose - > New -> Other -> Webservices -> WebService from WSDL and click Next.

    • Provide a class name and package name for the ejb class and choose the WSDL created in Step 1. Wait for sometime until Web Service Port appears and Click on Finish



  4. Now you have an EJB class with one method poll(org.hl7.v2xml.ADTA43CONTENT part1) . We need to invoke a webservice from this ejb module. So, create a webservice reference by following these steps:

    • Right Click on the ejb module. Choose Other -> Web Services -> Web Service Client.

    • Select the HL7 WSDL. (To create a HL7 WSDL see the STEP 1 in Inbound scenario). Click Finish



  5. Now, you can see a new folder created called Web Service References. Expand it until you see the operation. Drag and drop the operation into the ejb poll method. You will have code created for invoking the webservice. You need to marshall the JAXB object into XML string and pass the string for the method invocation. The code snippet should look like this: Code Snippet

  6. Create a Composite Application and deploy it.

    • Go To File -> New Project -> Service Oriented Architecture -> Composite Application. 

    • Provide a project name and finish the wizard.

    • Double Click on the Service Assembly to open the CASA editor.

    • Drag and drop the EJB Module into the CASA editor.

    • Build and deploy the Composite Application.




Place the test message in C:\\temp\\input.txt to test.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

vishblog

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today