2010/08/03

Cordys BOP4: Database connector

Introduction

Just 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.

Note:
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-AppServer

Within 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 Configuration

First we will create a database configuration which contains the database connection properties.
  1. Goto System Resource Manager

  2. Select Manage Database Configurations

  3. Select Insert Button

  1. Select MySql and fill database properties. Select green button to test the connection.
    Select Save to save this configuration.


Service Group

Next we will create a Service Group (WS-AppServer) that is the connection pool to the database.
  1. In the System Resource Manager goto Show all service groups

  2. Select Plus sign

  3. Select WS-AppServer as application connector and click Next

  1. Fill in Name and Select all Web Service Interfaces and click Next

  1. Fill in Name and select Automatic as Startup Type. Click Next.

  1. Check Configure Database and select the database configuration created above (Employee database). Click Next.
Notes:
  • 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. 

  1. Leave defaults and click Finish.

Database Metadata

Now 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.

  1. Create a Metadata Folder in you workspace

  2. Right click on the Folder and select Database Metadata document

  1. Select the Ws-AppServer service and click Save

  1. Fill in Name and Description and click Save

  1. 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 operations

Now 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.
  1. Generate Web Service Operations directly on the database
  2. Generate Java Code (WS-AppServer package)

  1. Generate Custom Web Service Operation

To generate webservice operations on the tables you have to do the following:
  1. Create a Web Services Folder

  2. Right click on the Employee Database Metadata and select Generate Web Service Operations

  1. Select the table on which the operations must be generated. In this case only one table (employee) is present. And click Finish.


  1. 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.

6 comments:

  1. Hey..have you used embeded wisapp to communicate witht the db.. ?

    ReplyDelete
  2. Hell Bijesh,

    No i have not done that yet.
    Did you have problems with it?
    I will try after my holidays ;)

    Regards
    Roger

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Yes in ,Working with multiple configurations in EMBEDDED wsapps.. i have two database configrations and im trying to communicate with different databases inside a function.. but its communicating always to the first set db..
    There is an article in wiki already mentioning about this issue..
    check this https://wiki.cordys.com/display/cui/XForm+File+Uploads+and+Downloads+to+Database?focusedCommentId=179308227#comment-179308227
    That solution is also help full for me.. i dont have a multi threaded scenario .. My Bop is CU6

    ReplyDelete
  5. Hi Roger van de Kimmenade,
    am new for Cordys bop4. am trying to configure database (i want to create new database in cordys) through system resources but its showing error like " 500 - ns0:Server :Configuration validation was not successful. " Can you please tell me whats wrong is going ? and please suggest any links or tutorials for learn cordys from scratch

    Thanks..

    ReplyDelete
    Replies
    1. Hello Bharat,

      Please look at the wiki.cordys.com (you can register for free).
      Then goto https://wiki.cordys.com/display/acorg/Cordys+Fundamentals+BOP+4.1 and there you will find the fundamentals training.

      Good luck !

      Regards, Roger

      Delete