Difference between revisions of "EclipseLink/Examples/DBWS/DBWSBasicStoredProcedure"

From Eclipsepedia

Jump to: navigation, search
Line 3: Line 3:
 
Given a procedure name, a Web Service is automatically generated that exposes the Stored Procedure(s) operation(s).
 
Given a procedure name, a Web Service is automatically generated that exposes the Stored Procedure(s) operation(s).
  
Note: From the metadata for a Stored Procedure, it is not possible to determine the structure of the returned data. Therefore, a simplified 'pseudo-rowset' schema is used.
+
Note: From the metadata for a Stored Procedure, it is not possible to determine the structure of the returned data. Therefore, the Simple XML Format schema is used.
  
 
'''XSD for Simple XML Format'''
 
'''XSD for Simple XML Format'''
Line 11: Line 11:
 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 
   >
 
   >
   <xsd:complexType name="sxfType">
+
   <xsd:complexType name="simple-xml-format">
 
     <xsd:sequence>
 
     <xsd:sequence>
 
       <xsd:any minOccurs="0"/>
 
       <xsd:any minOccurs="0"/>
 
     </xsd:sequence>
 
     </xsd:sequence>
 
   </xsd:complexType>
 
   </xsd:complexType>
  <xsd:element name="simple-xml-format" type="sxfType"/>
 
 
   </xsd:schema>
 
   </xsd:schema>
 
</div>
 
</div>
  
The EclipseLink DBWS runtime produces an XML document-fragment that is simple and 'human-readable'; however, the document is 'dumb' as it cannot be validated against any XML schema (elements underneath <srvc:result> are not namespace-qualified).
+
The EclipseLink DBWS runtime produces an XML document-fragment that is simple and 'human-readable'; however, the document is 'dumb' as it cannot be validated against any XML schema.
  
 
Element tag names are direct copies of table's column names
 
Element tag names are direct copies of table's column names
Line 30: Line 29:
 
  <env:Header/>
 
  <env:Header/>
 
  <env:Body>
 
  <env:Body>
   <srvc:findAllEmployeesResponse
+
   <srvc:findAllEmployeesResponse xmlns:srvc="urn:empService">
    xmlns:srvc="urn:empService">
+
 
   <srvc:result>
 
   <srvc:result>
 
     <simple-xml-format>
 
     <simple-xml-format>
Line 69: Line 67:
 
   <env:Header/>
 
   <env:Header/>
 
   <env:Body>
 
   <env:Body>
     <srvc:employeesWithCommissionResponse
+
     <srvc:employeesWithCommissionResponse xmlns:srvc="urn:empService">
      xmlns:srvc="urn:empService">
+
 
       <srvc:result>
 
       <srvc:result>
         <employee-list
+
         <employee-list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="any">
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
          xsi:type="any">
+
 
           <employee>
 
           <employee>
 
             <EMPNO>7499</EMPNO>
 
             <EMPNO>7499</EMPNO>

Revision as of 11:51, 2 April 2009

EclipseLink DBWS Service based on Stored Procedure

Given a procedure name, a Web Service is automatically generated that exposes the Stored Procedure(s) operation(s).

Note: From the metadata for a Stored Procedure, it is not possible to determine the structure of the returned data. Therefore, the Simple XML Format schema is used.

XSD for Simple XML Format

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

The EclipseLink DBWS runtime produces an XML document-fragment that is simple and 'human-readable'; however, the document is 'dumb' as it cannot be validated against any XML schema.

Element tag names are direct copies of table's column names

Resulting XML Document

<env:Envelope
 xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
 <srvc:findAllEmployeesResponse xmlns:srvc="urn:empService">
  <srvc:result>
   <simple-xml-format>
    <simple-xml>
     <EMPNO>7499</EMPNO>
     <ENAME>ALLEN</ENAME>
     <JOB>SALESMAN</JOB>
     <MGR>7698</MGR>
     <HIREDATE>1981-02-20T00:00:00.0</HIREDATE>
     <SAL>1600</SAL>
     <COMM>300</COMM>
     <DEPTNO>30</DEPTNO>
    </simple-xml>
    . . .
    <simple-xml>
     <EMPNO>7844</EMPNO>
     <ENAME>TURNER</ENAME>
     <JOB>SALESMAN</JOB>
     <MGR>7698</MGR>
     <HIREDATE>1981-09-08T00:00:00.0</HIREDATE>
     <SAL>1500</SAL>
     <COMM>0</COMM>
     <DEPTNO>30</DEPTNO>
    </simple-xml>
   </simple-xml-format>
  </srvc:result>
 </srvc:findAllEmployeesResponse>
</env:Body>
</env:Envelope>

NB: The element-tags <simple-xml-format> and <simple-xml> can be customized:

<env:Envelope
 xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
 <env:Header/>
 <env:Body>
   <srvc:employeesWithCommissionResponse xmlns:srvc="urn:empService">
     <srvc:result>
       <employee-list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="any">
         <employee>
           <EMPNO>7499</EMPNO>
           <ENAME>ALLEN</ENAME>
           <JOB>SALESMAN</JOB>
           <MGR>7698</MGR>
           <HIREDATE>1981-02-20T00:00:00.0</HIREDATE>
           <SAL>1600</SAL>
           <COMM>300</COMM>
           <DEPTNO>30</DEPTNO>
         </employee>
         . . .
         <employee>
           <EMPNO>7844</EMPNO>
           <ENAME>TURNER</ENAME>
           <JOB>SALESMAN</JOB>
           <MGR>7698</MGR>
           <HIREDATE>1981-09-08T00:00:00.0</HIREDATE>
           <SAL>1500</SAL>
           <COMM>0</COMM>
           <DEPTNO>30</DEPTNO>
         </employee>
       </employee-list>
     </srvc:result>
   </srvc:employeesWithCommissionResponse>
 </env:Body>
</env:Envelope>

Any combination of IN, OUT and IN OUT arguments are supported; in addition, procedures in packages that are overloaded - same name, different parameters – are supported.