Jump to: navigation, search

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

(New page: TBD)
 
Line 1: Line 1:
TBD
+
<css>
 +
  .source-sql {padding:4px;}
 +
  .source-java5 {padding:4px;border:1px solid black;}
 +
  .source-xml {padding:4px;border:1px solid black;}
 +
  .source-text {padding:4px;border:1px solid black;}
 +
</css>
 +
__NOTOC__
 +
 
 +
== EclipseLink DBWS Service based on an overloaded Stored Procedure ==
 +
The use-case for this example is the creation of a Web service that exposes a Stored Procedure (or multiple procedures).
 +
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. The EclipseLink DBWS runtime produces an XML document that is simple and 'human-readable'.
 +
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.
 +
 
 +
The following stored procedures will be used for this example: <source lang="sql"  enclose="div">
 +
CREATE OR REPLACE PROCEDURE P1(SIMPLARRAY IN TBL1, FOO IN VARCHAR2) AS
 +
BEGIN
 +
  // do something
 +
END P1;
 +
 
 +
CREATE OR REPLACE PROCEDURE P1(SIMPLARRAY IN TBL1, FOO IN VARCHAR2, BAR IN VARCHAR2) AS
 +
BEGIN
 +
  // do something
 +
END P1;
 +
</source>
 +
 
 +
The <tt>DBWSBuilder</tt> utility requires a DBWS configuration file as input.
 +
<source lang="xml" enclose="div">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 +
  <properties>
 +
    <property name="projectName">testEcho</property>
 +
    ... database properties
 +
  </properties>
 +
  <procedure
 +
    name="overloadedProcedureTest"
 +
    procedurePattern="P1"
 +
    isSimpleXMLFormat="true"
 +
  />
 +
</dbws-builder>
 +
</source>
 +
<source lang="text">
 +
prompt > dbwsbuilder.cmd -builderFile dbws-builder.xml -stageDir output_directory -packageAs wls testEcho.war
 +
</source>
 +
 
 +
where
 +
* <tt>dbws-builder.xml</tt> is the DBWS builder XML file above
 +
* <tt>output_directory</tt> is the output directory for the generated files
 +
* <tt>-packageAs</tt> specifies the platform on which the web service will be deployed
 +
 
 +
The generated <tt><b>eclipselink-dbws-schema.xsd</b></tt> file is the schema for the Simple XML format:
 +
<source lang="xml" enclose="div">
 +
<?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>
 +
</source>
 +
The element tags <tt><b>simple-xml-format</b></tt> and <tt><b>simple-xml</b></tt> can be customized by setting the appropriate properties
 +
on an <tt>sql</tt> operation.
 +
[[Category:EclipseLink/Example/DBWS]]

Revision as of 12:44, 10 June 2011


EclipseLink DBWS Service based on an overloaded Stored Procedure

The use-case for this example is the creation of a Web service that exposes a Stored Procedure (or multiple procedures). 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. The EclipseLink DBWS runtime produces an XML document that is simple and 'human-readable'. 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.

The following stored procedures will be used for this example:
CREATE OR REPLACE PROCEDURE P1(SIMPLARRAY IN TBL1, FOO IN VARCHAR2) AS
BEGIN
  // do something
END P1;

CREATE OR REPLACE PROCEDURE P1(SIMPLARRAY IN TBL1, FOO IN VARCHAR2, BAR IN VARCHAR2) AS
BEGIN
  // do something
END P1;

The DBWSBuilder utility requires a DBWS configuration file as input.

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <properties>
    <property name="projectName">testEcho</property>
    ... database properties
  </properties>
  <procedure
   name="overloadedProcedureTest"
   procedurePattern="P1"
   isSimpleXMLFormat="true"
 />
</dbws-builder>
prompt > dbwsbuilder.cmd -builderFile dbws-builder.xml -stageDir output_directory -packageAs wls testEcho.war

where

  • dbws-builder.xml is the DBWS builder XML file above
  • output_directory is the output directory for the generated files
  • -packageAs specifies the platform on which the web service will be deployed

The generated eclipselink-dbws-schema.xsd file is the schema for the 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 element tags simple-xml-format and simple-xml can be customized by setting the appropriate properties on an sql operation.