IntroductionJust like any other Enterprise Service Bus, Cordys BOP4 also has connectors like file, ftp, mail and database.
This blog item shows how a database connector is configured within the product.
Within a Service Oriented Architecture that must be flexible and product independant I would advise not to use product specific
database connectors. I would recommend to implement an abstraction layer around the database with for instance Hibernate and expose it as a webservice.
Ws-AppServerWithin the Cordys BOP4 platform a database connector is implemented with a so-called Ws-AppServer. This is a java layer between the database and can be used to implement some business logic
and/or the place to react on database events.
For this example I have used a MySql database instance (Test) with an Employee table.
DROP TABLE IF EXISTS test.Employee; CREATE TABLE test.Employee ( EmployeeNumber varchar(255) NOT NULL DEFAULT '', FirstName varchar(255) NOT NULL DEFAULT '', LastName varchar(255), BirthDate date NOT NULL, PRIMARY KEY (EmployeeNumber) ); INSERT INTO `test`.`Employee` (EmployeeNumber, FirstName, LastName, BirthDate) VALUES (1,'Roger', 'van de Kimmenade', '1971-12-04');
Database ConfigurationFirst we will create a database configuration which contains the database connection properties.
- Goto System Resource Manager
- Select Manage Database Configurations
- Select Insert Button
- Select MySql and fill database properties. Select green button to test the connection.
Select Save to save this configuration.
Service GroupNext we will create a Service Group (WS-AppServer) that is the connection pool to the database.
- In the System Resource Manager goto Show all service groups
- Select Plus sign
- Select WS-AppServer as application connector and click Next
- Fill in Name and Select all Web Service Interfaces and click Next
- Fill in Name and select Automatic as Startup Type. Click Next.
- Check Configure Database and select the database configuration created above (Employee database). Click Next.
- The Initializer Class Name is the name of the class that implements theiOnBsfConnectorinterface. This helps you implement custom logic that will run whenever WS-AppServer starts or stops.
- Leave defaults and click Finish.
Database MetadataNow we can generate a Database MetaData object that represents the structure of a database. It uses the metadata service to connect to the database and get the details.
- Create a Metadata Folder in you workspace
- Right click on the Folder and select Database Metadata document
- Select the Ws-AppServer service and click Save
- Fill in Name and Description and click Save
- The database tables are loaded and shown. You can click on a table to view the columns. You can Save and close the window.
Generating webservice operationsNow we are ready to generate webservice operations on the database tables.
There are three ways to do that, but i will only describe the first in this blog item.
- Generate Web Service Operations directly on the database
- Generate Java Code (WS-AppServer package)
- Generate Custom Web Service Operation
To generate webservice operations on the tables you have to do the following:
- Create a Web Services Folder
- Right click on the Employee Database Metadata and select Generate Web Service Operations
- Select the table on which the operations must be generated. In this case only one table (employee) is present. And click Finish.
- When you look in the Web Services Folder you can see the generated data and webservice operations
This concludes this blog about generating webservices on your database.