You are on page 1of 2

Webservice callout provides webservices access from the database, typically, for

PL/SQL clients. This utility is based on JPublisher 10g Release 2 (10.2) and O
racle WebService 10g Release 3 (10.1.3).
1. Webservice Callout using JPublisher
1.1. Setup
JPublisher 10g can generate database-side Java and PL/SQL wrappers
from the WSDL file of a webservice through the JPublisher command
line option -proxywsdl. In order for JPublisher to generate
and load wrappers for webservice clients into the database,
the dbwsa.jar and dbwsclient.jar files, included in
this download, must be present in the classpath and inside the
database respectively. The procedure below setup the environment
and the database for JPublisher-supported WebService callout.
1) If you are not running JPublisher 10g Release 2, download and install
JPublisher 10g Release 2 (10.2) from the site
http://otn.oracle.com/software/tech/java/sqlj_jdbc/index.html
2) Make sure the dbwsa.jar is added to the directory
ORACLE_HOME\sqlj\lib (NT) or ORACLE_HOME/sqlj/lib (Solaris).
3) Set up JDK 1.4 or later as the Java VM and Java compiler.
4) Add dbwsa.jar to the classpath environment variable
5) Load the dbwsclient.jar file into the SYS schema or
into the schema where the webservice client will be invoked.
For instance, the following loadjava command load
dbwsclient.jar into SYS.
% loadjava -u sys/change_on_install -r -v -f -s -grant public -noverify -genm
issing dbwsclient.jar
One can also load the dbwsclient.jar file into a specific
schema, for example, using
% loadjava -u scott/tiger -r -v -f -noverify -genmissing dbwsclient.jar
1.2. Example
Deploy the webservice javacallout to an OC4J instance.
% java -jar $J2EE_HOME/admin.jar ormi://localhost oc4jadmin welcome -deploy -
file samples/javacallout.ear -deploymentName javacallout
% java -jar $J2EE_HOME/admin.jar ormi://localhost oc4jadmin welcome -bindWebA
pp javacallout javacallout http-web-site /javacallout
The samples/javacallout.wsdl file is the WSDL file
for the webservices deployed above. The command
% jpub -u scott/tiger -sysuser sys/change_on_install
-proxywsdl=sample/javacallout.wsdl
-endpoint=http://localhost:8888/javacallout/javacallout -dir=tmp
create the webservice client, and its Java and PL/SQL wrappers i
in the subdirectory tmp and then load those wrappers in the database.
The output from the command above would be
tmp/HelloServiceEJBJPub.java
tmp/plsql_wrapper.sql
tmp/plsql_dropper.sql
tmp/plsql_grant.sql
tmp/plsql_revoke.sql
Executing tmp/plsql_dropper.sql
Executing tmp/plsql_wrapper.sql
Executing tmp/plsql_grant.sql
Loading tmp/plsql_proxy.jar
The user can invoke the PL/SQL functions provided in
tmp/plsql_wrapper.sql. Each PL/SQL function corresponds
to an operation in that Web Service. For example, if
the webservice is available at the endpoint
http://localhost:8888/javacallout/javacallout, the SQL
command
SQL> select jpub_plsql_wrapper.sayhello('hello') from dual;
will return
JPUB_PLSQL_WRAPPER.SAYHELLO('HELLO')
-----------------------------------
HELLO!! You just said :hello
For details about JPublisher callout support, please refer
to JPublisher User's Guide (10g) from
http://otn.oracle.com/documentation/database10g.html
2. Webservice Callout through SYS.UTL_DBWS Utilities
2.1. Setup
The PL/SQL user can invoke WebServices using the PL/SQL
package SYS.UTL_DBWS, which provides wrappers functions
for the JAXRPC dynamic invocation APIs. The following
procedure applies to Oracle Database 10g Release 1 or
later. The procedure sets up the database for webservice
callout using SYS.UTL_DBWS, or refresh SYS.UTL_DBWS
distributed with Oracle 10g Databases with more recent
features provided in this download.
1) Load dbwsclient.jar using the instruction in 1.1.
2) Execute utl_dbws_decl.sql and utl_dbws_body.sql as SYS.
Now you are ready to use SYS.UTL_DBWS to call webservices.
2.2. Example
The SQL scripts samples/test-plsql-dii.sql and
samples/test-plsql-dii2.sql invokes the sayHello
operation defined in javacallout.wsdl. Examine the two
scripts for their correspondences with the WSDL file.
Both scripts output the result
PL/SQL DII client return hello
For documentation on SYS.UTL_DBWS, please refer to
PL/SQL Packages and Types Reference 10g Releases
from http://otn.oracle.com/documentation/database10g.html.

You might also like