Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/DBWS/Creating EclipseLink DBWS Services (ELUG)"

(Undo revision 143965 by Michael.norman.oracle.com (Talk))
Line 1: Line 1:
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
+
<div style="float:right;border:1px solid #000000;padding:5px;max-width:475px;">__TOC__
 
[[Special:Whatlinkshere/Creating Deployment Files for EclipseLink Database Web Services (ELUG)|Related Topics]]</div>
 
[[Special:Whatlinkshere/Creating Deployment Files for EclipseLink Database Web Services (ELUG)|Related Topics]]</div>
  
 
==Creating Deployment Files for EclipseLink Database Web Services ==
 
==Creating Deployment Files for EclipseLink Database Web Services ==
  
This section describes how to automatically generate a WAR file containing the WSDL and XML schema files along with all deployment files that an EclipseLink Database Web service requires.  
+
This section describes how to automatically generate a WAR file containing the WSDL and XML schema files along with all deployment files that an EclipseLink Database Web Services (DBWS) requires.  
  
 
This section describes the following:  
 
This section describes the following:  
*[[#How to Create Deployment Files for an EclipseLink Database Web Service Using DBWSBuilder|How to Create Deployment Files for an EclipseLink Database Web Service Using DBWSBuilder]]
+
*[[#How to Create Deployment Files for an EclipseLink DBWS Using DBWSBuilder|How to Create Deployment Files for an EclipseLink DBWS Using DBWSBuilder]]
*[[#How to Customize an EclipseLink Database Web Service Using Java Through Session Customization|How to Customize an EclipseLink Database Web Service Using Java Through Session Customization]]
+
*[[#How to Customize an EclipseLink DBWS Using Java Through Session Customization|How to Customize an EclipseLink DBWS Using Java Through Session Customization]]
*[[#How to Customize an EclipseLink Database Web Service Using project.xml and  sessions.xml|How to Customize an EclipseLink Database Web Service Using project.xml and  sessions.xml]]
+
*[[#How to Customize an EclipseLink DBWS Using project.xml and  sessions.xml|How to Customize an EclipseLink DBWS Using project.xml and  sessions.xml]]
*[[#What You May Need to Know About Creating Deployment Files for an EclipseLink Database Web Service|What You May Need to Know About Creating Deployment Files for an EclipseLink Database Web Service]]
+
*[[#What You May Need to Know About Creating Deployment Files for an EclipseLink DBWS|What You May Need to Know About Creating Deployment Files for an EclipseLink DBWS]]
 
*[[#Binding|Binding]]
 
*[[#Binding|Binding]]
 
*[[#DBWSBuilder|DBWSBuilder]]
 
*[[#DBWSBuilder|DBWSBuilder]]
  
=== How to Create Deployment Files for an EclipseLink Database Web Service Using DBWSBuilder ===
+
=== How to Create Deployment Files for an EclipseLink DBWS Using DBWSBuilder ===
You can use the EclipseLink Database Web Service design-time tool called DBWSBuilder to create deployment files. DBWSBuilder (in package <tt>eclipselink.tools.dbws</tt>) is a Java application that processes the operations described in a eclipselink-dbws-builder.xml file (see [[EclipseLink dbws-builder.xml File (ELUG)#eclipselink-dbws-builder.xml|eclipselink-dbws-builder.xml]]) to produce all the required deployment artifacts.  
+
You can use the EclipseLink DBWS design-time tool called DBWSBuilder to create deployment files. DBWSBuilder is a Java application that processes the operations described in an EclipseLink DBWS builder XML file (see [[EclipseLink dbws-builder.xml File (ELUG)#eclipselink-dbws-builder.xml|EclipseLink DBWS builder XML file]]) to produce all the required deployment artifacts.  
  
 
Be sure to set the following environment variables (in the <tt><ECLIPSELINK_HOME>\utils\dbws\setenv.cmd</tt> or <tt>.sh</tt> file) before invoking DBWSBuilder:
 
Be sure to set the following environment variables (in the <tt><ECLIPSELINK_HOME>\utils\dbws\setenv.cmd</tt> or <tt>.sh</tt> file) before invoking DBWSBuilder:
Line 23: Line 23:
 
There are script files provided for invoking the DBWSBuilder. They are located in <tt><ECLIPSELINK_HOME>\utils\dbws</tt>. The scripts are '''dbwsbuilder.cmd''' for Windows usage and '''dbwsbuilder.sh''' for other operating systems.
 
There are script files provided for invoking the DBWSBuilder. They are located in <tt><ECLIPSELINK_HOME>\utils\dbws</tt>. The scripts are '''dbwsbuilder.cmd''' for Windows usage and '''dbwsbuilder.sh''' for other operating systems.
  
<tt>
+
<blockquote style="padding:4px;border:1px solid black;">
prompt > dbwsbuilder.cmd {path_to_eclipselink_dbws_builder.xml_file} -output {path_to_output_directory}  
+
<code>DBWSBuilder usage ([] indicates optional argument):<br>
</tt>
+
prompt> dbwsbuilder.cmd -builderFile {path_to_builder.xml} -stageDir {path_to_stageDir} -packageAs[:archive_flag] {packager} [additional arguments]<br>
 +
Available packagers:<br>
 +
&nbsp;&nbsp;-packageAs:[default=not supported] jdev<br>
 +
&nbsp;&nbsp;-packageAs:[default=archive] javase [jarFilename]<br>
 +
&nbsp;&nbsp;-packageAs:[default=archive] wls [warFilename]<br>
 +
&nbsp;&nbsp;-packageAs:[default=noArchive] xr [jarFilename]</code>
 +
</blockquote>
  
Using DBWSBuilder, you can generate an EclipseLink Database Web Service from the  following sources:  
+
Using DBWSBuilder, you can generate an EclipseLink DBWS from the  following sources:  
 
*an existing relational database table;  
 
*an existing relational database table;  
 
*one or more SQL statements written with respect to an existing relational database schema;  
 
*one or more SQL statements written with respect to an existing relational database schema;  
Line 33: Line 39:
  
  
To create deployment files for your EclipseLink Database Web Service, do the following:  
+
To create deployment files for your EclipseLink DBWS , do the following:  
 
#Create the table in your relational database and ensure that the relational database  management system is online.  
 
#Create the table in your relational database and ensure that the relational database  management system is online.  
# Execute DBWSBuilder. Optionally, specify a SessionCustomizer class name using the DBWSBuilder property '''orSessionCustomizerClassName''' (if you are customizing the EclipseLink object-relational mappings), or '''oxSessionCustomizerClassName''' (when customizing the EclipseLink XML mappings).  
+
#Execute DBWSBuilder. Optionally, specify a SessionCustomizer class name using the DBWSBuilder property '''orSessionCustomizerClassName''' (if you are customizing the EclipseLink object-relational mappings), or '''oxSessionCustomizerClassName''' (when customizing the EclipseLink XML mappings).  
#Package and deploy the EclipseLink Database Web Service.  
+
#Package and deploy the EclipseLink DBWS.  
  
  
===== Using the eclipselink-dbws-builder.xml File to Create Deployment Files for a Eclipselink Database Web Service Using DBWSBuilder from a Database Table =====
+
===== Using the eclipselink-dbws-builder.xml File to Create Deployment Files for a Eclipselink DBWS  Using DBWSBuilder from a Database Table =====
  
'''''Using eclipselink-dbws-builder.xml File to Create an EclipseLink Database Web Service from a Table '''''
+
'''''Using eclipselink-dbws-builder.xml File to Create an EclipseLink DBWS  from a Table '''''
 
<source lang="xml">
 
<source lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 
+
  <properties>  
 
+
    <property name="projectName">crud</property>  
<properties>  
+
    <property name="logLevel">off</property>  
<property name="projectName">crud</property>  
+
    <property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property>  
<property name="logLevel">off</property>  
+
    <property name="driver">oracle.jdbc.OracleDriver</property>  
<property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property>  
+
        <property name="dataSource">jdbc/DBWSPoolDS</property>  
<property name="driver">oracle.jdbc.OracleDriver</property>  
+
    <property name="username">scott</property>  
<property name="dataSource">jdbc/DBWSPoolDS</property>  
+
    <property name="password">tiger</property>  
<property name="username">scott</property>  
+
    <property name="platformClassname">eclipselink.platform.database.oracle.Oracle10Platform</property>  
<property name="password">tiger</property>  
+
  </properties>  
<property name="platformClassname">eclipselink.platform.database.oracle.Oracle10Platform</property>  
+
  <table catalogPattern="%" tableNamePattern="XR_CRUD_TABLE"/>  
</properties>  
+
 
+
<table catalogPattern="%" tableNamePattern="XR_CRUD_TABLE"/>  
+
 
+
 
</dbws-builder>  
 
</dbws-builder>  
 
</source>
 
</source>
  
===Using the eclipselink-dbws-builder.xml File to Create Deployment Files for an Eclipselink Database Web Service Using DBWSBuilder from SQL ===
+
===Using the eclipselink-dbws-builder.xml File to Create Deployment Files for an Eclipselink DBWS Using DBWSBuilder from SQL ===
  
 
<span id="Example 9-2"></span>
 
<span id="Example 9-2"></span>
''''' Using eclipselink-dbws-builder.xml File to Create an EclipseLink Database Web Service from SQL '''''
+
''''' Using eclipselink-dbws-builder.xml File to Create an EclipseLink DBWS from SQL '''''
  
 
<source lang="xml">
 
<source lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 
+
  <properties>
 
+
    <property name="projectName">employee</property>  
<properties>  
+
    <property name="driver">oracle.jdbc.OracleDriver</property>  
<property name="projectName">employee</property>  
+
    <property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property>  
<property name="driver">oracle.jdbc.OracleDriver</property>  
+
    <property name="username">scott</property>  
<property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property>  
+
    <property name="password">tiger</property>  
<property name="username">scott</property>  
+
  </properties>  
<property name="password">tiger</property>  
+
  <sql name="employeeInfo" simpleXMLFormatTag="employee-info" xmlTag="aggregate-counts" >  
 
+
    <text>  
 
+
      <![CDATA[select count(*) as "COUNT", max(SAL) as "MAX-Salary" from EMP]]>  
</properties>  
+
    </text>  
<sql name="employeeInfo" simpleXMLFormatTag="employee-info" xmlTag="aggregate-counts" >  
+
  </sql>  
 
+
</dbws-builder>
<text>  
+
<![CDATA[select count(*) as "COUNT", max(SAL) as "MAX-Salary" from EMP]]>  
+
</text>  
+
</sql>  
+
</dbws-builder>  
+
 
+
 
</source>
 
</source>
  
 
For more information, see [[EclipseLink dbws-builder.xml File (ELUG)#What You May Need to Know About Builder Operations|What You May Need to Know About Builder Operations]].  
 
For more information, see [[EclipseLink dbws-builder.xml File (ELUG)#What You May Need to Know About Builder Operations|What You May Need to Know About Builder Operations]].  
  
===== Using the eclipselink-dbws-builder.xml File to Create Deployment Files for an Eclipselink Database Web Service Using DBWSBuilder from a Stored Procedure =====
+
===== Using the eclipselink-dbws-builder.xml File to Create Deployment Files for an Eclipselink DBWS Using DBWSBuilder from a Stored Procedure =====
  
 
<span id="Example 9-3"></span>
 
<span id="Example 9-3"></span>
Line 102: Line 98:
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<?xml version="1.0" encoding="UTF-8"?>  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
 
+
  <properties>  
 
+
    <property name="projectName">employee</property>  
<properties>  
+
    <property name="driver">oracle.jdbc.OracleDriver</property>  
<property name="projectName">employee</property>  
+
    <property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property>  
<property name="driver">oracle.jdbc.OracleDriver</property>  
+
    <property name="username">scott</property>  
<property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property>  
+
    <property name="password">tiger</property>  
<property name="username">scott</property>  
+
    </properties>  
<property name="password">tiger</property>  
+
  <procedure returnType="empType"  
 
+
    catalogPattern="SOME_PKG"  
 
+
    schemaPattern="SCOTT"  
</properties>  
+
    procedurePattern="GetEmployeeByEMPNO_DEPTNO"/>
 
+
  </procedure>  
 
+
<procedure returnType="empType"  
+
catalogPattern="SOME_PKG"  
+
schemaPattern="SCOTT"  
+
procedurePattern="GetEmployeeByEMPNO_DEPTNO"/>  
+
 
+
 
+
</procedure>  
+
 
</dbws-builder>  
 
</dbws-builder>  
 
</source>
 
</source>
Line 127: Line 115:
 
For more information, see [[EclipseLink dbws-builder.xml File (ELUG)#What You May Need to Know About Builder Operations|What You May Need to Know About Builder Operations]].  
 
For more information, see [[EclipseLink dbws-builder.xml File (ELUG)#What You May Need to Know About Builder Operations|What You May Need to Know About Builder Operations]].  
  
===== How to Customize a Eclipselink Database Web Service Using Java Through Session Customization =====
+
===== How to Customize a Eclipselink DBWS Using Java Through Session Customization =====
You can customize an EclipseLink database Web service with an EclipseLink  
+
You can customize an EclipseLink DBWS with an EclipseLink SessionCustomizer as follows:  
SessionCustomizer as follows:  
+
 
<ol>
 
<ol>
 
<li>Implement a '''eclipselink.tools.sessionconfiguration.SessionCustomizer''', as  this example shows. <br>
 
<li>Implement a '''eclipselink.tools.sessionconfiguration.SessionCustomizer''', as  this example shows. <br>
 
<span id="Example 9-4"></span><br>
 
<span id="Example 9-4"></span><br>
 
''''' Implementing a SessionCustomizer '''''
 
''''' Implementing a SessionCustomizer '''''
 
 
<source lang="java">
 
<source lang="java">
import eclipselink.tools.sessionconfiguration.SessionCustomizer;  
+
import org.eclipse.persistence.config;  
import eclipselink.sessions.Session;  
+
import org.eclipse.persistence.sessions.Session;  
import eclipselink.sessions.DatabaseLogin;  
+
import org.eclipse.persistence.sessions.DatabaseLogin;  
 
+
  
 
public class MySessionCustomizer implements SessionCustomizer {  
 
public class MySessionCustomizer implements SessionCustomizer {  
  
 
+
  public void customize(Sesssion session) {  
public void customize(Sesssion session) {  
+
    DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin();  
DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin();  
+
    login.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_UNCOMMITTED);  
login.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_UNCOMMITTED);  
+
  }  
}  
+
}
}  
+
 
</source>
 
</source>
 
<br>
 
<br>
For more information, see [[#EclipseLink Database Web Services Customization]]. </li>
+
For more information, see [[#EclipseLink DBWS Customization]]. </li>
 
<li>Add the SessionCustomizer to the classpath. </li>
 
<li>Add the SessionCustomizer to the classpath. </li>
 
<li>Set the following environment variables:
 
<li>Set the following environment variables:

Revision as of 13:38, 12 March 2009

Related Topics

Creating Deployment Files for EclipseLink Database Web Services

This section describes how to automatically generate a WAR file containing the WSDL and XML schema files along with all deployment files that an EclipseLink Database Web Services (DBWS) requires.

This section describes the following:

How to Create Deployment Files for an EclipseLink DBWS Using DBWSBuilder

You can use the EclipseLink DBWS design-time tool called DBWSBuilder to create deployment files. DBWSBuilder is a Java application that processes the operations described in an EclipseLink DBWS builder XML file (see EclipseLink DBWS builder XML file) to produce all the required deployment artifacts.

Be sure to set the following environment variables (in the <ECLIPSELINK_HOME>\utils\dbws\setenv.cmd or .sh file) before invoking DBWSBuilder:

  • $JAVA_HOME
  • $DRIVER_CLASSPATH

There are script files provided for invoking the DBWSBuilder. They are located in <ECLIPSELINK_HOME>\utils\dbws. The scripts are dbwsbuilder.cmd for Windows usage and dbwsbuilder.sh for other operating systems.

DBWSBuilder usage ([] indicates optional argument):
prompt> dbwsbuilder.cmd -builderFile {path_to_builder.xml} -stageDir {path_to_stageDir} -packageAs[:archive_flag] {packager} [additional arguments]
Available packagers:
  -packageAs:[default=not supported] jdev
  -packageAs:[default=archive] javase [jarFilename]
  -packageAs:[default=archive] wls [warFilename]
  -packageAs:[default=noArchive] xr [jarFilename]

Using DBWSBuilder, you can generate an EclipseLink DBWS from the following sources:

  • an existing relational database table;
  • one or more SQL statements written with respect to an existing relational database schema;
  • a stored procedure.


To create deployment files for your EclipseLink DBWS , do the following:

  1. Create the table in your relational database and ensure that the relational database management system is online.
  2. Execute DBWSBuilder. Optionally, specify a SessionCustomizer class name using the DBWSBuilder property orSessionCustomizerClassName (if you are customizing the EclipseLink object-relational mappings), or oxSessionCustomizerClassName (when customizing the EclipseLink XML mappings).
  3. Package and deploy the EclipseLink DBWS.


Using the eclipselink-dbws-builder.xml File to Create Deployment Files for a Eclipselink DBWS Using DBWSBuilder from a Database Table

Using eclipselink-dbws-builder.xml File to Create an EclipseLink DBWS from a Table

<?xml version="1.0" encoding="UTF-8"?> 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  <properties> 
    <property name="projectName">crud</property> 
    <property name="logLevel">off</property> 
    <property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property> 
    <property name="driver">oracle.jdbc.OracleDriver</property> 
        <property name="dataSource">jdbc/DBWSPoolDS</property> 
    <property name="username">scott</property> 
    <property name="password">tiger</property> 
    <property name="platformClassname">eclipselink.platform.database.oracle.Oracle10Platform</property> 
  </properties> 
  <table catalogPattern="%" tableNamePattern="XR_CRUD_TABLE"/> 
</dbws-builder>

Using the eclipselink-dbws-builder.xml File to Create Deployment Files for an Eclipselink DBWS Using DBWSBuilder from SQL

Using eclipselink-dbws-builder.xml File to Create an EclipseLink DBWS from SQL

<?xml version="1.0" encoding="UTF-8"?> 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  <properties>
    <property name="projectName">employee</property> 
    <property name="driver">oracle.jdbc.OracleDriver</property> 
    <property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property> 
    <property name="username">scott</property> 
    <property name="password">tiger</property> 
  </properties> 
  <sql name="employeeInfo" simpleXMLFormatTag="employee-info" xmlTag="aggregate-counts" > 
    <text> 
      <![CDATA[select count(*) as "COUNT", max(SAL) as "MAX-Salary" from EMP]]> 
    </text> 
  </sql> 
</dbws-builder>

For more information, see What You May Need to Know About Builder Operations.

Using the eclipselink-dbws-builder.xml File to Create Deployment Files for an Eclipselink DBWS Using DBWSBuilder from a Stored Procedure

Using eclipselink-dbws-builder.xml File to Create an EclipseLink Database Web Service from Stored Procedure

<?xml version="1.0" encoding="UTF-8"?> 
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  <properties> 
    <property name="projectName">employee</property> 
    <property name="driver">oracle.jdbc.OracleDriver</property> 
    <property name="url">jdbc:oracle:thin:@localhost:1521:ORCL</property> 
    <property name="username">scott</property> 
    <property name="password">tiger</property> 
    </properties> 
  <procedure returnType="empType" 
    catalogPattern="SOME_PKG" 
    schemaPattern="SCOTT" 
    procedurePattern="GetEmployeeByEMPNO_DEPTNO"/>
  </procedure> 
</dbws-builder>

For more information, see What You May Need to Know About Builder Operations.

How to Customize a Eclipselink DBWS Using Java Through Session Customization

You can customize an EclipseLink DBWS with an EclipseLink SessionCustomizer as follows:

  1. Implement a eclipselink.tools.sessionconfiguration.SessionCustomizer, as this example shows.

    Implementing a SessionCustomizer
    import org.eclipse.persistence.config; 
    import org.eclipse.persistence.sessions.Session; 
    import org.eclipse.persistence.sessions.DatabaseLogin; 
     
    public class MySessionCustomizer implements SessionCustomizer { 
     
      public void customize(Sesssion session) { 
        DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin(); 
        login.setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_UNCOMMITTED); 
      } 
    }


    For more information, see #EclipseLink DBWS Customization.
  2. Add the SessionCustomizer to the classpath.
  3. Set the following environment variables:
    • $JAVA_HOME
    • $DRIVER_CLASSPATH
  4. Execute DBWSBuilder using the following command:
    $ dbwsbuilder.cmd -builderFile (path to eclipselink dbws_builder.xml file) -stageDir {path to output directory} -packageAs (javase | jdev | wls)
    When executing the DBWSBuilder, specify the SessionCustomizer class name using the DBWSBuilder property orSessionCustomizerClassName (if you are customizing the EclipseLink object-relational mappings), or oxSessionCustomizerClassName (when customizing the EclipseLink XML mappings). For more information, see the following:
  5. Package and deploy the EclipseLink database Web service.
How to Customize an Eclipselink Database Web Service Using project.xml and sessions.xml

You can customize an EclipseLink database Web service by creating your own project.xml and sessions.xml files, as follows:

  1. Set the following environment variables:
    • $JAVA_HOME
    • $DRIVER_CLASSPATH
  2. Execute DBWSBuilder using the following command:
    $ dbwsbuilder.cmd -builderFile (path to eclipselink dbws_builder.xml file) -stageDir {path to output directory} -packageAs (javase | jdev | wls) This creates the necessary EclipseLink database Web service files and subdirectories. For more information, see the following:
  3. Manually create your project.xml files and sessions.xml file using your tool of choice.
      • Map your objects to your relational database in an EclipseLink relational project
      • Map your objects to your XML schema in an EclipseLink XMl project
  4. Add both projects to your session.

    Note: Your custom sessions.xml file must use the same name as specified by the DBWSBuilder property sessionsFileName (see eclipselink-dbws-builder.xml File Elements (DBWSBuilder Properties)).

    For more information, see the following:

  5. Replace the generated project.xml files and sessions.xml file in your EclipseLink database Web services directory hierarchy with your custom project.xml files and sessions.xml files.
  6. Execute DBWSBuilder. For more information, see the following:
  7. Package and deploy the EclipseLink database Web service.

What You May Need to Know About Creating Deployment Files for an EclipseLink Database Web Service

This figure illustrates the process for creating EclipseLink database Web service deployment files.

Creating EclipseLink Database Web Service Deployment Files

This illustration shows the process for creating EclipseLink database Web service deployment files. The EclipseLink database Web service design-time tool takes your XSD and database schema as input to generate from table, SQL, stored procedure, or package and create a WAR file containing an EclipseLink database Web service xr-service.xml file, an EclipseLink database Web service WSDL file, EclipseLink object-relational and XML project.xml files, and EclipseLink sessions.xml file.

This section describes the following:

  • EclipseLink Database Web Services WAR File
  • Unstructured Data
  • EclipseLink Database Web Services Customization

For more information, see the following:


EclipseLink Database Web Services WAR File

When you generate an EclipseLink database Web service, all generated files are packaged into a WAR file, as this example shows. EclipseLink Database Web Service WAR File Contents lists the files in these WAR files.

EclipseLink Database Web Services WAR File

root of WAR file 
 web-inf
 web.xml
 web-inf/
   oracle-webservices.xml 
   web.xml 
 classes/ 
   com/ // optional domain classes 
     acme/ 
       Address.class 
       Employee.class 
      PhoneNumber.class 
   META-INF/ 
     eclipselink-dbws.xml 
     eclipselink-dbws-sessions.xml // override eclipselink-dbws.xml sessions-file 
     eclipselink-dbws-or.xml 
     eclipselink-dbws-ox.xml 
   _dbws
     DBWSProvider.class
     DBWSProvider.java
 wsdl/ 
   eclipselink-dbws.wsdl 
   swaref.xsd  // optional
   eclipselink-dbws-schema.xsd 


EclipseLink Database Web Service WAR File Contents

File Description

index.html

Default EclipseLink database Web service landing page. The name and content of this file is determined by its role in Web deployment and cannot be changed. Applicable to all WAR files.

swaref.xsd

Contains XML type definitions for attachments. The name and content of this file is determined by its role in Web deployment and cannot be changed.

eclipselink-dbws-schema.xsd

Contains XML type definitions for operation arguments and return types. The EclipseLink database Web service automatically generates this file from your database table metadata and uses it to derive element-tag names and types. For more information, see eclipselink-dbws-schema.xsd.

MANIFEST.MF

The manifest file for the WAR file.

web.xml

The Web application deployment file that binds the EclipseLink database Web service to Web services stack servlet.

eclipselink-dbws.xml

The EclipseLink database Web services configuration file. For more information, see eclipselink-dbws.xml File.

eclipselink-dbws-sessions .xml

The EclipseLink sessions.xml file for this EclipseLink database Web service. It contains references to the EclipseLink relational and object-XML project.xml files. For more information, see Introduction to EclipseLink Sessions (ELUG).

eclipselink-dbws-or.xml

The EclipseLink relational project.xml file. For more information, see Introduction to Relational Projects (ELUG).

eclipselink-dbws-ox.xml

The EclipseLink object-XML project.xml file. For more information, see Introduction to XML Projects (ELUG).

eclipselink-dbws.wsdl

Contains equivalent entries for each operation for the specified EclipseLink database Web service. Required for deployment as a Web service.

Before you can deploy the EclipseLink database Web service, you must package the WAR in the appropriate Java EE archive for your application, such as an EAR.

Unstructured Data

In some circumstances, an EclipseLink database Web services operation may return unstructured data rather than a persistent entity. For example:

  • a resultSet from a custom SQL SELECT statement;
  • information returned by a Stored Procedure;
  • scalar results such as from a Stored Function or a count of updated-rows from an update operation.

The OC4J Web services provider will return such unstructured data as documents that conform to the Simple XML Format (SXF) schema shown in this example.

Simple XML Format XSD for Unstructured Data

<?xml version="1.0" encoding="UTF-8"?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<xsd:complexType name="sxfType"> 
<xsd:sequence> 
<xsd:any minOccurs="0"/> 
 
 
</xsd:sequence> 
 
 
</xsd:complexType> 
 
 
<xsd:element name="simple-xml-format" type="sxfType"/> 
</xsd:schema>

The following example shows a typical unstructured data document. Note the following:

  • Element tag names are direct copies of table column names.
  • The default root-element tag name is simple-xml-format and each row uses the tag name simple-xml. You can customize these element tag names using simpleXMLFormatTagand xmlTag attributes of builder operations (see Common Attributes of Builder Operations).
  • Columnar data uses tag names taken either from the database schema (the actual database column name) or from the stored procedure, stored function, or trigger.


Example Unstructured Data Document

<simple-xml-format> 
<simple-xml> 
<ENAME>SCOTT</ENAME> 
<JOB>ANALYST</JOB> 
<MGR>7566</MGR> 
<HIREDATE>1987-04-19T00:00:00.000-0400</HIREDATE> 
<SAL>3000</SAL> 
<DEPTNO>20</DEPTNO> 
</simple-xml> 
<simple-xml> 
<ENAME>SMITH</ENAME> 
<JOB>CLERK</JOB> 
<MGR>7902</MGR> 
<HIREDATE>1980-12-17T00:00:00.000-0400</HIREDATE> 
<SAL>800</SAL> 
<DEPTNO>20</DEPTNO> 
</simple-xml> 
 
 
</simple-xml-format>


EclipseLink Database Web Services Customization

To customize an EclipseLink database Web service, you can do the following:

  • Implement an EclipseLink SessionCustomizer class.

A SessionCustomizer is a Java class that implements the eclipselink.tools.sessionconfiguration.SessionCustomizer interface and provides a default (zero-argument) constructor.

Use this class's customizemethod, which takes an eclipselink.sessions.Session, to programmatically access advanced EclipseLink session API. Using this API you can get object relational and XML descriptors and from descriptors, you can get object relational and XML mappings.

In this way, you can access all session, descriptor, and mapping API to customize any part of the EclipseLink runtime that the EclipseLink database Web service generates. For example, to turn off the session cache. This approach is best when you just want to customize a few details.

You specify the SessionCustomizerusing DBWSBuilder properties (see eclipselink-dbws-builder.xml and #DBWSBuilder).

By default, the session names are defined based on the eclipselink-dbws.xml file (see eclipselink-dbws.xml File) name attribute as follows:

  • relational session name: name-dbws-or-session
  • object-xml session name: name-dbws-ox-session
  • Manually generate project.xml files and sessions.xml file.

Using your preferred tool you can map your objects to your relational database in an EclipseLink relational project, map your objects to your XML schema in an EclipseLink XMl project, and create an EclipseLink sessions.xmlfile that references both projects.

In this way, you can control all aspects of the relational and XML mapping. This approach is best when you want to customize most or all details.


Binding

The binding nested element of the sqlbuilder operation is an EclipseLink database Web services function that you use to bind an argument in an SQL statement to an XSD data type (see Attributes of the sql Operation). You define this element in the eclipselink-dbws-build.xml file (see eclipselink-dbws-build.xml File).


Attributes of the binding Element

Attribute Description Required name The name of the stored procedure, stored function, or trigger to execute. The parent builder operation specifies the database that provides the stored procedure, stored function, or trigger. Yes type The XSD data type to bind to the argument name. Yes


This example shows a typical sql operation that specifies arguments using nested bindingelements. The order in which you define bindingelements must match the order of the arguments in your SQL statement.

SQLOperation Task: With Binding Elements for Arguments

... 
 
 
<sql name="findXREmpByName" isCollection="true" returnType="xr_empType"> 
<text> 
<![CDATA[select * from EMP where EMPNO = ? and LAST_NAME = ?]]> 
</text> 
<binding name="EMPNO" type="xsd:int"/> 
<binding name="LAST_NAME" type="xsd:string"/> 
 
 
</sql> 
...

For more information, see eclipselink-dbws-builder.xml.

DBWSBuilder

The EclipseLink database Web service design-time tool, DBWSBuilder, is a Java application that produces EclipseLink database Web service files and assembles them into a Web Archive (WAR) file.

You set the DBWSBuilder’s properties (see eclipselink-dbws-builder.xml File Elements (DBWSBuilder Properties)) to define features of your EclipseLink database Web service.

You can also set the design-time tool’s properties, add table and procedure definitions, and SQL operations programmatically through the API. Use the eclipselink.tools.dbws.DBWSBuilder class’s methods such as setDriver, setProjectName, setURL, and so on, to set properties; the addDbTableand addDbStoredProceduremethods-to add table and procedure definitions; and the addSQLOperation method-to add SQL operations.

Note: Before adding a table or procedure definition, ensure that the definitions are supported by calling the checkTablesand checkStoredProcedures methods.

Once you set all the data and definitions, invoke the builder using its build method.




Copyright Statement

Back to the top