Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/DBWS/Creating from an Overloaded Stored Procedure"

m (New page: {{EclipseLink_UserGuide |info=y |toc=n |eclipselink=y |eclipselinktype=DBWS }} ==Creating from an Overloaded PL/SQL Stored Procedure == Starting in release 2.3, EclispeLink DBWS can creat...)
 
m (Example)
Line 15: Line 15:
 
In this example, the stored procedure contains different parameters:
 
In this example, the stored procedure contains different parameters:
  
 
+
<source lang="plsql" enclose="div">
 
CREATE PROCEDURE P(SIMPLARRAY IN TBL1, FOO IN VARCHAR2) AS
 
CREATE PROCEDURE P(SIMPLARRAY IN TBL1, FOO IN VARCHAR2) AS
 
BEGIN
 
BEGIN
Line 24: Line 24:
 
   -- (same name 'P') 3 arguments SIMPLARRAY, FOO and BAR
 
   -- (same name 'P') 3 arguments SIMPLARRAY, FOO and BAR
 
END P;
 
END P;
 +
</source>
  
 
EclipseLink DBWS supports any combination of the '''IN''', '''OUT''' and '''IN OUT''' arguments.
 
EclipseLink DBWS supports any combination of the '''IN''', '''OUT''' and '''IN OUT''' arguments.
  
Type TBL1 is defined in PL/SQL Package SOMEPACKAGE as follows:
+
Type '''TBL1''' is defined in PL/SQL Package '''SOMEPACKAGE''' as follows:
 +
<source lang="plsql" enclose="div">
 
CREATE OR REPLACE PACKAGE SOMEPACKAGE AS
 
CREATE OR REPLACE PACKAGE SOMEPACKAGE AS
 
   TYPE TBL1 IS TABLE OF VARCHAR2(111) INDEX BY BINARY_INTEGER;
 
   TYPE TBL1 IS TABLE OF VARCHAR2(111) INDEX BY BINARY_INTEGER;
Line 33: Line 35:
 
   PROCEDURE P(SIMPLARRAY IN TBL1, FOO IN VARCHAR2, BAR IN VARCHAR2);
 
   PROCEDURE P(SIMPLARRAY IN TBL1, FOO IN VARCHAR2, BAR IN VARCHAR2);
 
END SOMEPACKAGE;
 
END SOMEPACKAGE;
 +
</source>
 +
 +
The''' DBWSBuilder''' utility requires a DBWS configuration file as input, as shown here:
  
The DBWSBuilder utility requires a DBWS configuration file as input.
+
<source lang="xml" enclose="div">
 
<?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">
Line 47: Line 52:
 
   />
 
   />
 
</dbws-builder>
 
</dbws-builder>
 +
</source>
  
prompt > dbwsbuilder.cmd -builderFile dbws-builder.xml -stageDir output_directory -packageAs wls testEcho.war
+
Use this command to execute the '''DBWSBuilder''':
 +
prompt > dbwsbuilder.cmd -builderFile dbws-builder.xml -stageDir output_directory -packageAs wls testEcho.war
  
 
where
 
where
 +
* <tt>dbws-builder.xml</tt> is the DBWS configuration file (as shown previously)
 +
* <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
  
    * dbws-builder.xml is the DBWS builder XML file above
+
When generating queries and the WSDL in which overloaded procedures are used, a unique index identifies each procedure. The index starts at '''1''' and increments by one, for each overloaded procedure.
    * output_directory is the output directory for the generated files
+
    * -packageAs specifies the platform on which the web service will be deployed
+
  
When generating queries and the WSDL when overloaded procedures are present, an index is used to uniquely identify each procedure. The index starts at 1, and incremented for each overloaded procedure. The generated eclipselink-dbws.wsdl for this example follows.  :
+
In this example, EclipseLink generates the following '''eclipselink-dbws.wsdl''' (Web Services Description Language):
 +
<source lang="xml" enclose="div">
 
<wsdl:definitions
 
<wsdl:definitions
 
     name="plsqloverloadService"
 
     name="plsqloverloadService"
Line 136: Line 145:
 
     </wsdl:service>
 
     </wsdl:service>
 
</wsdl:definitions>
 
</wsdl:definitions>
 +
</source>

Revision as of 18:14, 26 October 2011

EclipseLink DBWS

link="http://wiki.eclipse.org/EclipseLink"
EclipseLink
Website
Download
Community
Mailing ListForumsIRC
Bugzilla
Open
Help Wanted
Bug Day
Contribute
Browse Source


Creating from an Overloaded PL/SQL Stored Procedure

Starting in release 2.3, EclispeLink DBWS can create a web service that exposes multiple PL/SQL stored procedures. Instead of specifying all the stored procedures within the DBWS builder file, you can specify a single procedure name and "overload" it with different parameters.

Note: This feature requires a database, such as Oracle, that supports overloading.


Example

In this example, the stored procedure contains different parameters:

CREATE PROCEDURE P(SIMPLARRAY IN TBL1, FOO IN VARCHAR2) AS
BEGIN
  -- 2 arguments SIMPLARRAY and FOO
END P;
CREATE PROCEDURE P(SIMPLARRAY IN TBL1, FOO IN VARCHAR2, BAR IN VARCHAR2) AS
BEGIN
  -- (same name 'P') 3 arguments SIMPLARRAY, FOO and BAR
END P;

EclipseLink DBWS supports any combination of the IN, OUT and IN OUT arguments.

Type TBL1 is defined in PL/SQL Package SOMEPACKAGE as follows:

CREATE OR REPLACE PACKAGE SOMEPACKAGE AS
  TYPE TBL1 IS TABLE OF VARCHAR2(111) INDEX BY BINARY_INTEGER;
  PROCEDURE P(SIMPLARRAY IN TBL1, FOO IN VARCHAR2);
  PROCEDURE P(SIMPLARRAY IN TBL1, FOO IN VARCHAR2, BAR IN VARCHAR2);
END SOMEPACKAGE;

The DBWSBuilder utility requires a DBWS configuration file as input, as shown here:

<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <properties>
    <property name="projectName">testOverloadedProcedure</property>
    ... database properties
  </properties>
  <plsql-procedure
   name="overloadedProcedure"
   catalogPattern="SOMEPACKAGE"
   procedurePattern="P"
 />
</dbws-builder>

Use this command to execute the DBWSBuilder:

prompt > dbwsbuilder.cmd -builderFile dbws-builder.xml -stageDir output_directory -packageAs wls testEcho.war

where

  • dbws-builder.xml is the DBWS configuration file (as shown previously)
  • output_directory is the output directory for the generated files
  • -packageAs specifies the platform on which the web service will be deployed

When generating queries and the WSDL in which overloaded procedures are used, a unique index identifies each procedure. The index starts at 1 and increments by one, for each overloaded procedure.

In this example, EclipseLink generates the following eclipselink-dbws.wsdl (Web Services Description Language):

<wsdl:definitions
    name="plsqloverloadService"
    targetNamespace="urn:plsqloverloadService"
    xmlns:ns1="urn:plsqloverload"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="urn:plsqloverloadService"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   >
    <wsdl:types>
        <xsd:schema elementFormDefault="qualified" targetNamespace="urn:plsqloverloadService" xmlns:tns="urn:plsqloverloadService"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <xsd:import namespace="urn:plsqloverload" schemaLocation="eclipselink-dbws-schema.xsd"/>
            <xsd:complexType name="p1ResponseType">
                <xsd:sequence>
                    <xsd:element name="result">
                        <xsd:complexType><xsd:sequence><xsd:any/></xsd:sequence></xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="p1RequestType">
                <xsd:sequence>
                    <xsd:element name="SIMPLARRAY" type="ns1:SOMEPACKAGE_TBL1"/>
                    <xsd:element name="FOO" type="xsd:string"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="p2ResponseType">
                <xsd:sequence>
                    <xsd:element name="result">
                        <xsd:complexType><xsd:sequence><xsd:any/></xsd:sequence></xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="p2RequestType">
                <xsd:sequence>
                    <xsd:element name="SIMPLARRAY" type="ns1:SOMEPACKAGE_TBL1"/>
                    <xsd:element name="FOO" type="xsd:string"/>
                    <xsd:element name="BAR" type="xsd:string"/>
                </xsd:sequence>
            </xsd:complexType>
            <xsd:element name="p2" type="tns:p2RequestType"/>
            <xsd:element name="p1" type="tns:p1RequestType"/>
            <xsd:element name="p1Response" type="tns:p1ResponseType"/>
            <xsd:element name="p2Response" type="tns:p2ResponseType"/>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="p2Request"><wsdl:part name="p2Request" element="tns:p2"/></wsdl:message>
    <wsdl:message name="p2Response"><wsdl:part name="p2Response" element="tns:p2Response"/></wsdl:message>
    <wsdl:message name="p1Request"><wsdl:part name="p1Request" element="tns:p1"/></wsdl:message>
    <wsdl:message name="p1Response"><wsdl:part name="p1Response" element="tns:p1Response"/></wsdl:message>
    <wsdl:portType name="plsqloverloadService_Interface">
        <wsdl:operation name="p2">
            <wsdl:input message="tns:p2Request"/>
            <wsdl:output message="tns:p2Response"/>
        </wsdl:operation>
        <wsdl:operation name="p1">
            <wsdl:input message="tns:p1Request"/>
            <wsdl:output message="tns:p1Response"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="plsqloverloadService_SOAP_HTTP" type="tns:plsqloverloadService_Interface">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="p2">
            <soap:operation soapAction="urn:plsqloverloadService:p2"/>
            <wsdl:input><soap:body use="literal"/></wsdl:input>
            <wsdl:output><soap:body use="literal"/></wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="p1">
            <soap:operation soapAction="urn:plsqloverloadService:p1"/>
            <wsdl:input><soap:body use="literal"/></wsdl:input>
            <wsdl:output><soap:body use="literal"/></wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="plsqloverloadService">
        <wsdl:port name="plsqloverloadServicePort" binding="tns:plsqloverloadService_SOAP_HTTP">
            <soap:address location="REPLACE_WITH_ENDPOINT_ADDRESS"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>