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 logicand/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.- 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 Group
Next 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 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.- 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 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.
- 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.
Hey..have you used embeded wisapp to communicate witht the db.. ?
BeantwoordenVerwijderenHell Bijesh,
BeantwoordenVerwijderenNo i have not done that yet.
Did you have problems with it?
I will try after my holidays ;)
Regards
Roger
Deze reactie is verwijderd door de auteur.
BeantwoordenVerwijderenYes 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..
BeantwoordenVerwijderenThere 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
Hi Roger van de Kimmenade,
BeantwoordenVerwijderenam 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..
Hello Bharat,
VerwijderenPlease 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