OpenEAI ServiceGen

Background

The OpenEAI MOA Generation (MoaGen) Application already automates the generation of a Java API and Schema definitions from message object definitions and sample messages. The goal of this project is to automate additional steps in the ESB and Web Service development life cycle.

Goals

To automate specific steps of the OpenEAI ESB and Web Service development life cycle. Specifically, these tools will:

  1. Generate skeleton request commands and/or sync commands using a completed service/application configuration document provided by the developer.
  2. Generate a test suite application configuration for the service based on the configuration document for the application being tested provided by the developer.
  3. Generate the WSDL and AXIS web service facade to proxy request operations to the ESB service. This facade exposes request operations of the ESB service as a WSDL described web service.
  4. Generate Hibernate persistence mappings for a MOA.

Scope

These commands can be chained together to automate the generation of a complete set of artifacts, but sometimes it is necessary to isolate these steps

Application Name

Purpose

Command Example

Outputs

CommandGen

To generate template request and sync commands

./run hellohibernate gen-service

A java project with template commands and the scripts to build the project

TestSuiteAppGen

To generate a configuration document for a deployment of the test suite application to test a service

./run hellohibernate gen-testsuite 

An OpenEAI configuration document for the desired test suite application and a sample test script generated using sample Moa data.

Axis2ServiceGen

To generate WSDL, supporting XML schema, and an Axis2 web service facade

./run hellohibernate gen-webservice  

WSDL, supporting XSDs referenced in the WSDL, the Axis2 service facade source, the deployable Axis2 archive (aar), and compiled wsdl classes jar file.

HibernateMappingGen

To generate Hibernate persistence mappings for a MOA

./run hellohibernate gen-service  

hibernate mapping files

Design

Test Run

Using MppiService as an example to test run:

1) checkout project from https://svn.service.emory.edu:8443/cgi-bin/viewvc.cgi/emoryoit/project/openeai-servicegen/,

2) modify properties/mppi.properties as appropriate, and (App properties file)

 a) Modify build.properties file.  Make emoryoit.home point to your emoryoit SVN checkout directory on local machine.  For Windows users example: "C:\\emoroit_checkouts\\"

3) at command line type: ./run mppi for build, or ./start mppi for start service and testsuite app (for running the service and testsuite app locally, first-time user please see OpenEAI ServiceGen)

Sample artifacts of a test run:

Sample output of the web service invoked using SoapUI:

Usage Examples

Example 1: Creating GwGreetingService from scratch

1) Creating MOA definition dtd and sample messages

<!ELEMENT GwGreetee (GwFullName)> 
<!ELEMENT GwGreeting (Text)> 

2) Using Sonic Management Console, creating Username/Password, Destinations and JMS Administered Objects

Username/Password=GwGreetingService/XXXXXX

Destination:

GwGreetingServiceQueue

JMS Administered Objects:

cn=GwGreetingServiceQueue
cn=GwGreetingServiceTopic
cn=GwGreetingServiceConsumerQCF
cn=GwGreetingServiceConsumerTCF
cn=GwGreetingServiceProducerQCF
cn=GwGreetingServiceProducerTCF

3) Creating properties/gwgreeting.properties

#####################################################################################################################
##################### openeai-servicegen properties ################################
#####################################################################################################################
#for project naming such as openeai-hellohibernate-webservice
project.prefix=openeai
#####################################################################################################################
#optional
#moa.jar.filepath=/Users/gwang28/project/emoryoit/deployment/esb/promote/actsi-moas/actsi-moas/moagen/build/lib/actsi-moa.jar
#optional, to limit ws geneartion of operations to only those who has PrimedXmlDocument element
#service.appconfig.filepath=/Users/gwang28/project/emoryoit/project/openeai-gen/mppiAppConfig.xml

#####################################################################################################################
#to access jms server, also used as wsdl.id
service.name=GwGreetingService
service.password=password
#####################################################################################################################

#####################################################################################################################
#usully origin of the moa such as com.oracle, etc
moa.package.prefix=org.openeai.tutorial
#for naming of application.id and service.package.name, and webservice code generation from wsdl
#usually edu.emory or org.openeai
service.name.prefix=org.openeai
#####################################################################################################################

#####################################################################################################################
#for generation of moas.xml, moas.xsd, and appConfig.xml
segment.dtd.filepath=${openeai.home}/message/releases/org/openeai/tutorial/Resources/1.0/Segments.dtd
message.category.filepath=${openeai.home}/message/releases/org/openeai/tutorial/Sample
#####################################################################################################################

#####################################################################################################################
##these are for cleaner buld (webservices files and wsdl, but not for temp moas). They are
##not needed if the project has its own separate segmentUri file
##
##if not specified, use all folders files under the message.category.filepath
##commma delimited list
actionables=GwGreeting
#####################################################################################################################

./run gwgreeting deploy service for generating the projects and deploy it
./service gwgreeting for start the service

./test gwgreeting for start the testuite

4) Generating projects and webservice by running

5) Using the projects generated to jump start:

example-moas can be used out-of-box for moa generation
openeai-example-service for service development
openeai-example-testsuite for running testsuites
openeai-example-webservice can be used as out-of-box webservice implementation

If service has already been created, moa.jar.filepath and service.appconfig.filepath can be provided so that only testsuite and webservice projects be generated.

Example 2: Creating HelloHibernateGwService from scratch

1) Creating MOA definition dtd and sample messages

<!ELEMENT HelloHibernateGw (Id,Message?,MessageNumber?,LastModifiedDatetime?,LastModifiedDate?)>
<!ELEMENT HelloHibernateGwQuerySpecification (Comparison*,Id?,Message?,LastModifiedDate?,StartDate?,EndDate?)>
<!ELEMENT HelloHibernateGwMessage (Id?,Message?,LastModifiedDatetime?,LastModifiedDate?)>

Tips: you can use the newobject script to help you create the sample message, then use validate to verify.  Please see OpenEAI ServiceGen for detail.

2) Using Sonic Management Console, creating Username/Password, Destinations and JMS Administered Objects

Username/Password=HelloHibernateGwService/XXXXXX

Destination:

HelloHibernateGwServiceQueue

JMS Administered Objects:

cn=HelloHibernateGwServiceQueue
cn=HelloHibernateGwServiceTopic
cn=HelloHibernateGwServiceConsumerQCF
cn=HelloHibernateGwServiceConsumerTCF
cn=HelloHibernateGwServiceProducerQCF
cn=HelloHibernateGwServiceProducerTCF

3) Creating properties/hellohibernategw.properties in configs folder:

#####################################################################################################################
##################### openeai-servicegen properties ################################
#####################################################################################################################
#for project naming such as openeai-hellohibernate-webservice
project.prefix=openeai
#####################################################################################################################
#optional
#moa.jar.filepath=/Users/gwang28/project/emoryoit/deployment/esb/promote/actsi-moas/actsi-moas/moagen/build/lib/actsi-moa.jar
#optional, to limit ws geneartion of operations to only those who has PrimedXmlDocument element
#service.appconfig.filepath=/Users/gwang28/project/emoryoit/project/openeai-gen/mppiAppConfig.xml

#####################################################################################################################
#to access jms server, also used as wsdl.id
service.name=HelloHibernateGwService
service.password=password
#####################################################################################################################

#####################################################################################################################
#usully origin of the moa such as com.oracle, etc
moa.package.prefix=org.openeai.tutorial
#for naming of application.id and service.package.name, and webservice code generation from wsdl
#usually edu.emory or org.openeai
service.name.prefix=org.openeai
#####################################################################################################################

#####################################################################################################################
#for generation of moas.xml, moas.xsd, and appConfig.xml
segment.dtd.filepath=${openeai.home}/message/releases/org/openeai/tutorial/Resources/1.0/Segments.dtd
message.category.filepath=${openeai.home}/message/releases/org/openeai/tutorial/Sample
#####################################################################################################################

#####################################################################################################################
##these are for cleaner buld (webservices files and wsdl, but not for temp moas). They are
##not needed if the project has its own separate segmentUri file
##
##if not specified, use all folders files under the message.category.filepath
##commma delimited list
actionables=HelloHibernateGw
#####################################################################################################################

#####################################################################################################################
##optional, required for serviceHibernate only
#jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
##when jdbc.url is defined, hibernate mapping will be generated which requires that xalan-j-jar/lib/*.jar be in your
##endorsed folder of the jdk
#jdbc.url=jdbc:oracle:thin:@ldap://oranamesrvr2.cc.emory.edu/esb30dev,cn=OracleContext,dc=emory,dc=edu
#jdbc.username=esb30
#jdbc.password=xxxx
#hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
jdbc.driverClassName=org.hsqldb.jdbc.JDBCDriver
jdbc.url=jdbc:hsqldb:hellohibernatedb
jdbc.username=SA
jdbc.password=
#####################################################################################################################

./run hellohibernategw  #for generating the projects

4) Generating projects and webservice by running

5) Running service and TestSuite

./serviceHibernate hellohibernategw #to start the service
./test hellohibernategw  #to run the testsuite

 

6) Check generated artifacts

 -open target/hellohibernategw folder and review the generated artifacts

High-lighted files:

FilesDescriptions
openeai-hellohibernategw-service-1.0.jarExampleRequestCommand which produces Sample messages
openeai-hellohibernategw-webservice-1.0-dev.aaraxis2 web service that can be deployed to the dev environment out of box
openeai-hellohibernategw-webservice-1.0-wsdl-classes.jarclasses which support the .aar file and should be deployed to the axis2.war/WEB-INF/lib directory
hellohibernategw-moa.jarmoa files generated locally
moas.xmlmoa object model generated from moa dtd definition file (Segments.dtd) and sample message files.  This is the model that drives the whole generation process internally

Project directories

ProjectsDescriptions
hellohibernategw-moasthe moas project folder.  This can be used as the project for moa generation
openeai-hellohibernategw-appconfigthe project that generated most appConfig files
openeai-hellohibernategw-schemathe project that generated moas.xml
openeai-hellohibernategw-servicethe esb service project that has the ExampleRequestCommand.  It also has hibernate related artifacts (all the jars needed, and hibernate.cfg.xml and all the .hbm.xml files
openeai-hellohibernategw-testsuitethe testsuite project that generates sample testsuite files
openeai-hellohibernategw-webservice

the webservice project that can be deployed out of box.  Please notice the 4 different .aar files named as -dev.aar, -localhost.aar, -qa.aar, and -prod.aar.  These .aar files only differs by one line in the wsdl files.  They are the same openeai-hellohibernategw-webservice-1.0-wsdl-classes.jar

Please notice the line  <module ref="openeai-authorization-module"/> in resources/services.xml file.   This means the web service will have openeai-authorization-module activated by default. Please see  OpenEAI ServiceGen, especially the how it works section.

 

 -open target/hellohibernategw/deploy/configs/messaging/Environments/Examples folder and review the created Jars constellation, EOs, TestSuites

 -open target/hellohibernategw/deploy/configs/messaging/Environments/Examples/Jars/HelloHibernateGwService/hibernate folder and review generated hibernate mapping files

Tutorial:

Follow the two Usage Examples above (especially the HelloHibernateGwService example), while replacing 'Gw' with your own initials of first name and last name

To generate hibernate mapping files using ./run <project.key> command, copy from openeai-servicegen/xalan-j-lib folder and put xalan.jar, serializer.jar, xercesImpl.jar and xml-apis.jar to the <java-home>/jre/lib/endorsed (In MS Windows) or  /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/endorsed (for Mac)  directory, as stated here http://xml.apache.org/xalan-j/faq.html#faq-N100EF.

For java 8, it can be put in /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext

Tips:

High quality sample moa messages are very important, because they are used in moa generation, hibernate mapping generation, and testsuite sample test data generation.  Please use an XML editor to verify all sample data. To facilitate easier passing of the testsuites, it is recommended the same identical sample object be used for Create, Query, Delete and Update actions.

Reference

 

For Hibernate mapping and complex query, please see Hibernate Persistence for OpenEAI RDBMS Connector and Design Considerations of QuerySpecification Objects with Logical and Comparison Operators and QueryLanguage Elements