|
|
(56 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | {{EclipseLink_UserGuide
| + | For the current version, see: |
− | |info=y
| + | '''[http://www.eclipse.org/eclipselink/documentation/2.4/dbws/toc.htm Developing Persistence Architectures Using EclipseLink Database Web Services, Release 2.4]''' |
− | |toc=y
| + | |
− | |eclipselink=y
| + | |
− | |eclipselinktype=DBWS
| + | |
− | }}
| + | |
| | | |
− | == EclipseLink DBWS Overview ==
| + | For EclispeLink DBWS Overview, see http://www.eclipse.org/eclipselink/documentation/2.4/dbws/overview.htm |
− | | + | |
− | <onlyinclude>
| + | |
− | 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.
| + | |
− | | + | |
− | EclipseLink DBWS includes two parts
| + | |
− | *[[EclipseLink/UserGuide/DBWS/Overview/Design time|A design-time component]] (<tt>DBWSBuilder</tt>)
| + | |
− | *[[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.
| + | |
− | | + | |
− | | + | |
− | An EclipseLink DBWS service may include any number of the following <b>operations</b>:
| + | |
− | # <b>insert</b> - inserts into the database persistent entities described by an XML document.
| + | |
− | # <b>update</b> - updates database persistent entities described by an XML document.
| + | |
− | # <b>delete</b> - removes from the database persistent entities described by an XML document.
| + | |
− | # <b>query</b> - retrieves from the database persistent entities described by an XML document. <br>Selection criteria for Query operations can be specified by:
| + | |
− | #* custom <tt>SQL SELECT</tt> statement
| + | |
− | #* Stored Procedure invocation
| + | |
− | #* EclipseLink Named Query (that can use the complete range of EclipseLink ORM Expression Framework APIs)
| + | |
− | #* JP-QL
| + | |
− | | + | |
− | The XML documents used by an <b>operation</b> conform to an XML Schema Definition (<tt>.xsd</tt> file).
| + | |
− | | + | |
− | ===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.
| + | |
− | [[Image:XRRunTime.png]]
| + | |
− | | + | |
− | ===Configuration===
| + | |
− | A typical EclipseLink DBWS service is packaged in an archive (<tt>.jar</tt> or <tt>.war</tt> file) with a service descriptor file
| + | |
− | <tt><b>eclipselink-dbws.xml</b></tt> in the META-INF directory (or WEB-INF/classes/META-INF when packaged in a <tt>.war</tt> file).
| + | |
− | To bridge the relational database and XML worlds, an EclipseLink sessions.xml <tt><b>eclipselink-dbws-sessions.xml</b></tt> 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
| + | |
− | <tt><b>eclipselink-dbws-schema.xsd</b></tt> which in conjunction with the OXM project, specifies how information from the database
| + | |
− | is to be 'shaped' into XML documents.
| + | |
− | | + | |
− | <source lang="text" enclose="div"></source>
| + | |
− | root of archive
| + | |
− | {not all files displayed ...}
| + | |
− | \---META-INF
| + | |
− | | eclipselink-dbws.xml
| + | |
− | | eclipselink-dbws-sessions.xml -- name can be overriden by <sessions-file> entry in eclipselink-dbws.xml
| + | |
− | | eclipselink-dbws-or.xml
| + | |
− | | eclipselink-dbws-ox.xml
| + | |
− | | eclipselink-dbws-schema.xsd -- when deployed in a .war file, located in a different directory
| + | |
− | fckLRThe EclipseLink DBWS service descriptor file <tt><b>eclipselink-dbws.xml</b></tt> is easy to read, with minimum required informationfckLRand simple defaults for omitted fields, allowing for both auto-generation by a utility or manual editing:fckLR* <b>&lt;name&gt;</b> of EclipseLink DBWS servicefckLR* <b>&lt;sessions-file&gt;</b> name of sessions.xml file - if not present, then <tt><b>eclipselink-dbws-sessions.xml</b></tt> will be usedfckLR* <b>operation</b> definitions (see the four types mentioned above)fckLRfckLR=====Example DBWS Service descriptor file=====fckLR<source lang="xml" enclose="div"></source>
| + | |
− | | + | |
− | <dbws xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
| + | |
− | <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>
| + | |
− | fckLRThe [[EclipseLink/UserGuide/DBWS/Overview/EclipseLink_DBWS_Service_Descriptor_File_(ELUG)|EclipseLink DBWS service descriptor file is described in full in the User Guide]].fckLRfckLR===XML Schema Definition===fckLRThe EclipseLink DBWS service schema file <tt><b>eclipselink-dbws-schema.xsd</b></tt> can be created by hand, or auto-generated by thefckLRdesign-time <tt>DBWSBuilder</tt> utility that derives XML element-tag names from Database metadata (column names, types, nullable, etc).fckLRfckLR====Example Simple XML Format (SXF) document====fckLRThe <tt>DBWSBuilder</tt> utility will not generate an XML Schema Definition when the information returned by a <b>query operation</b> has no pre-determined structure, such as:fckLR* a resultSet from a custom SQL <b>query operation</b>fckLR* the results from a Stored Procedure <b>query operation</b>fckLR* the row-count from an <b>update operation</b>fckLRIn these cases, the EclipseLink DBWS runtime provider uses information only available at the time of query execution to build the XMLfckLRdocument:fckLR<source lang="xml" enclose="div"></source>
| + | |
− | {Element tag names are direct copies of table's column names}
| + | |
− | | + | |
− | <simple-xml-format>
| + | |
− | <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>
| + | |
− | fckLRThese XML documents are 'dumb' as they cannot be validated against any pre-determined schema - or more accurately, only the followingfckLRvery <b>permissive</b> 'sequence-of-any' schema can validate such documents:fckLRfckLR====Simple XML Format Schema====fckLR<source lang="xml" enclose="div"></source>
| + | |
− | | + | |
− | <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
| + | |
− | <xsd:complextype name="simple-xml-format">
| + | |
− | <xsd:sequence>
| + | |
− | <xsd:any minoccurs="0"></xsd:any>
| + | |
− | </xsd:sequence>
| + | |
− | </xsd:complextype>
| + | |
− | </xsd:schema>
| + | |
− | fckLRThe element tags <tt><b>simple-xml-format</b></tt> and <tt><b>simple-xml</b></tt> can be customized by setting the appropriate propertiesfckLRon an <tt><b>operation</b></tt>.fckLR</dbws></sessions-file></onlyinclude>
| + | |
| | | |
| [[Category:DBWS]] | | [[Category:DBWS]] |