Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/DBWS/Overview"
(→XML-to-Relational Mapping (XRM)) |
(→XML-to-Relational Mapping (XRM)) |
||
Line 20: | Line 20: | ||
[[Image:XRRunTime.png]]<br/> | [[Image:XRRunTime.png]]<br/> | ||
EclipseLink DBWS includes two parts | EclipseLink DBWS includes two parts | ||
− | *[[EclipseLink/UserGuide/DBWS/Overview/Design time|<tt><b>DBWSBuilder</b></tt> command-line utility]] - the <tt><b>DBWSBuilder</b></tt> utility generates the deployment artifacts (while some | + | *[[EclipseLink/UserGuide/DBWS/Overview/Design time|<tt><b>DBWSBuilder</b></tt> command-line utility]] - the <tt><b>DBWSBuilder</b></tt> utility generates the deployment artifacts (while some files can be created manually, it is <b>much</b> simpler to use the utility). |
*[[EclipseLink/UserGuide/DBWS/Overview/Runtime|A Runtime Provider component]] that takes a service descriptor (along with related deployment artifacts) and realizes it as a JAX-WS 2.0 Web service. The runtime provider uses EclipseLink to bridge between the database and the XML SOAP Messages used by Web service clients. | *[[EclipseLink/UserGuide/DBWS/Overview/Runtime|A Runtime Provider component]] that takes a service descriptor (along with related deployment artifacts) and realizes it as a JAX-WS 2.0 Web service. The runtime provider uses EclipseLink to bridge between the database and the XML SOAP Messages used by Web service clients. | ||
Revision as of 11:16, 8 December 2011
EclipseLink DBWS
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Contents
EclipseLink DBWS Overview
EclipseLink DBWS provides Java EE-compliant, client-neutral access to relational database artifacts via a Web service. EclipseLink DBWS extends EclipseLink's core capabilities while leveraging its existing ORM and OXM components.
XML-to-Relational Mapping (XRM)
EclipseLink's ORM and OXM features provides the basis for a powerful bridge between a database's relational structure(s) and XML's hierarchical structure.
EclipseLink DBWS includes two parts
- DBWSBuilder command-line utility - the DBWSBuilder utility generates the deployment artifacts (while some files can be created manually, it is much simpler to use the utility).
- A Runtime Provider component that takes a service descriptor (along with related deployment artifacts) and realizes it as a JAX-WS 2.0 Web service. The runtime provider uses EclipseLink to bridge between the database and the XML SOAP Messages used by Web service clients.
An EclipseLink DBWS service may include any number of the following operations:
- insert - inserts into the database persistent entities described by an XML document.
- update - updates database persistent entities described by an XML document.
- delete - removes from the database persistent entities described by an XML document.
- query - retrieves from the database persistent entities described by an XML document.
Selection criteria for Query operations can be specified by:- custom SQL SELECT statement
- Stored Procedure invocation
- EclipseLink Named Query: can use the complete range of EclipseLink ORM Expression Framework APIs
Configuration
A typical EclipseLink DBWS service is packaged in an archive (typically a .war file) with a service descriptor file in the META-INF directory. To bridge the relational database and XML worlds, an EclipseLink sessions.xml file points to two Eclipse projects - one for the ORM side, the other for the OXM side. The service also requires an XML Schema Definition file which in conjunction with the OXM project, specifies how information from the database is to be 'shaped' into XML.
eclipselink-dbws.xml -- service descriptor file eclipselink-dbws-sessions.xml eclipselink-dbws-or.xml -- EclipseLink mapping file eclipselink-dbws-ox.xml -- EclipseLink mapping file eclipselink-dbws-schema.xsd -- XML Schema definition file
EclipseLink DBWS Service descriptor file
The EclipseLink DBWS Service descriptor file (eclipselink-dbws.xml) is easy to read with minimum required information and simple defaults for omitted fields. The service descriptor file is described in the User Guide.
<name>example</name>
<sessions-file>example-dbws-sessions.xml</sessions-file>
<query>
<name>countEmployees
<result>
<type>xsd:int</type>
</result>
<sql><!--[CDATA[select count(*) from EMP]]--></sql>
</name>
</query>
EclipseLink DBWS Service sessions.xml file
EclipseLink DBWS mapping files
EclipseLink DBWS Service schema file
The EclipseLink DBWS Service schema file (eclipselink-dbws-schema.xsd) can be created by hand, or auto-generated by the DBWSBuilder utility which derives XML element-tag names from Database metadata (column names, types, nullable, etc).
Simple XML Format (SXF)
The DBWSBuilder utility will not generate a schema file when the information returned by a query operation has no pre-determined structure:
- a resultSet from a custom SQL query operation
- the results from a Stored Procedure query operation
- the row-count from an update operation
In these cases, the EclipseLink DBWS runtime provider uses the resultSet's metadata to build the XML element tag names:
ResultSetMetaData rsmd = rs.getMetaData(); int colcount = rsmd.getColumnCount(); for (int i=1; i <= colcount; i++) { String elementName = rsmd.getColumnName(i).toLower(); //empno, ename, job ... }
<simple-xml>
<empno>7788</empno>
<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>
<empno>7369</empno>
<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>
These XML documents are 'dumb' as they cannot be validated against a schema - or more accurately, only the following very permissive 'sequence-of-any' schema can validate such documents:
Simple XML Format Schema
<xsd:complextype name="simple-xml-format">
<xsd:sequence>
<xsd:any minoccurs="0"></xsd:any>
</xsd:sequence>
</xsd:complextype>
</xsd:schema>
The element tags simple-xml-format and simple-xml can be customized by setting the appropriate properties on an operation