[Wsf-general] The configuration file for the database service

Chamil Thanthrimudalige chamil at wso2.com
Mon Feb 26 03:33:58 PST 2007


hi all,

The configurations for the DBService will be in a file with the  
extension "dbs". The configuration file so far looks like below.

<data-service name="UserDataService" targetNameSpace="http:// 
www.wso2.org/types">
	<connection>
		<driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
		<protocol>jdbc:derby:../database/WSO2WSAS_DB</protocol>
		<user>wso2wsas</user>
		<password>wso2wsas</password>
	</connection>
	<operation name="getUser">
		<input/>
		<output/>
	</operation>
</data-service>

Details on the connection section needs to be generalized. So I would  
like get some input from a JDBC expert no how best we can capture the  
details.

The input element will take the form of a list of parameters and a  
prepared sql statement. The question marks in the statement will be  
replaced with the values of the parameters in order when being  
executed. The parameter element will include the xpath expression to  
get the parameter value from the input message.
Eg:
<input>
	<parameter>row/name</parameter>
	<parameter>row/age</parameter>
	<sqlStatement>select * from user where name=? or age = ?</sqlStatement>
</input>

In JDBC the following bit code will create and execute the prepared  
statement.

PreparedStatement updateSales = con.prepareStatement(
         "UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ? ");
updateSales.setInt(1, 75);
updateSales.setString(2, "Colombian");
updateSales.executeUpdate():


The output can be custom formated in two easy ways. The type  
attribute will say which format is being used. "rename" means that it  
is a simple column rename and "template" will indicate that an xml  
template will be used.

First way is by doing a simple rename of the columns. Here the rename  
element will indicate the source column name by "from" attribute and  
target from "to" attribute.
Eg:
<output wrap-rows="rowName">
	<rename xmlns:my="http://www.wso2.org/types" from="ISINDEX"  
to="IndexedState"/>
</output>

Or else it can be formated using a xml template. Here the param  
element will indicate the column of the dataset.
Eg:
<output type="template" wrap-rows="rowName">
	<name><param colName="name"/></name>
	<age><param colName="age"/></age>
</optput>

The wrap-rows attribute on the output element will give the repeating  
container element for grouping the individual records. If it is not  
given then it is assumed that only a single row will be returned, if  
more than one result is returned then the system will throw an error.

If the output element is not given the output data will be formated  
using the default settings. Where no modifications of the column  
names will be done and an element called row will be used to wrap the  
column data. The values will be in an element with it's column name.
Eg:
<getUser>
	<row>
		<id>1</id>
		<name>x</name >
		<age>12</age>
	</row>
</getUser >

Comments about this approach and the format of the configuration file  
are most welcome and greatly appreciated.

Best Regards,
Chamil Thanthrimudalige








More information about the Wsf-general mailing list