Oracle9i Application Server Web Services Developer's Guide Release 2 (9.0.2) Part Number A95453-01 |
|
This chapter describes the Oracle9iAS Web Services features that allow you to easily create and run a client application that uses Oracle9iAS Web Services.
This chapter contains the following topics:
When you want to use Web Services you need to develop a client application. There are two types of Web Services clients: static web service clients and dynamic web service clients. A static web service client knows where a Web Service is located without looking up the service in a UDDI registry. A dynamic web service client performs a lookup to find the Web Service's location in a UDDI registry before accessing the service. Chapter 8, "Discovering and Publishing Web Services" provides detailed information on looking up Web Services in a UDDI registry.
Using a static client Oracle9iAS Web Services provides several options for locating Oracle9iAS Web Services, including:
After you locate a Web Service or after you obtain either the WSDL or client-side proxy Jar, you can build a client-side application that uses the Web Service.
Oracle9iAS Web Services supplies client-side programmers with the following files for deployed Web Services:
To obtain the WSDL service description for a Web Service, use the Web Service URL and append a query string. The format for the URL to obtain the WSDL service description is as follows (see Table 6-1 for a description of the URL components):
http://host:port/context-root/service?WSDL
or
http://host:port/context-root/service?wsdl
This command returns a WSDL description in the form service.wsdl
. The service.wsdl
description contains the WSDL for the Web Service named service, located at the specified URL. Using the WSDL that you obtain, you can build a client application to access the Web Service.
To obtain the client-side proxy Jar for a Web Service, use the Web Service URL and append a query string. The client-side proxy Jar file contains the proxy stubs class that supports building an application that communicates using SOAP to access the Web Service. The proxy class does the following:
The format for the URL to obtain the client-side proxy Jar is as follows (see Table 6-1 for a description of the URL components):
http://host:port/context-root/service?PROXY_JAR
or
http://host:port/context-root/service?proxy_jar
This command returns the file service
_proxy.jar
. The service
_proxy.jar
is a Jar file that contains the client-side proxy classes that you can use to build a client-side application to access the Web Service.
To obtain the client-side proxy source Jar for a Web Service, use the Web Service URL and append a query string. The format for the URL to obtain the client-side proxy source Jar is as follows (see Table 6-1 for a description of the URL components):
http://host:port/context-root/service?PROXY_SOURCE
or
http://host:port/context-root/service?proxy_source
This command returns the file service
_proxysrc.jar
. The file service
_proxysrc.jar
is a Jar file that contains the client-side proxy source files. This file represents the source code for the file service
_proxy.jar
associated with the service.
When you obtain the client-side proxy Jar file or the client-side proxy source Jar, you have the option of including a request parameter that specifies a package name for the generated client-side proxy classes or source files. If the Web Service's client-side Java class is part of a particular package, then you should specify the package name to match the client-side application's package name.
The format for the URL to obtain the client-side proxy Jar and specify the package name is as follows (see Table 6-1 for a description of the URL components):
http://host:port/context-root/service?PROXY_JAR&packageName=mypackage
or
http://host:port/context-root/service?proxy_jar&packageName=mypackage
This command returns the file service
_proxy.jar
. The service
_proxy.jar
is a Jar file that contains the client-side proxy classes, using the specified package, mypackage
for the Java package
statement.
The format for the URL to obtain the client-side proxy source Jar and specify the package name is as follows (see Table 6-1 for a description of the URL components):
http://host:port/context-root/service?PROXY_SOURCE&packageName=mypackage
or
http://host:port/context-root/service?proxy_source&packageName=mypackage
This command returns the file service
_proxysrc.jar
. As for the proxy_jar
, you have the option of specifying a request parameter with a supplied package name by include a packageName=
name
option. The service
proxy_src.jar
is a Jar file that contains the client-side source files for the client-side proxy that accesses the Web Service.
This section describes how to use the client-side proxy Jar when you are building the client-side application on a system with Oracle9iAS. When building client-side applications to access and use services under Oracle9iAS Web Services, the Oracle9iAS Web Services client-side proxy Jar class allows you to easily build the application.
The client side proxy Jar file that you get from a Web Service contains a Java class to serve as a proxy to the Web Service implementation residing on the Oracle9iAS Web Services server. The client-side proxy code constructs a SOAP request and marshalls and unmarshalls parameters for you. Using the proxy classes saves you the work of creating SOAP requests for accessing a Web Service or processing Web Service responses.
Example 6-1 shows a source code sample client-side proxy extracted from a Web Service. For each method available on the Web Service, there is a corresponding method in the proxy class. The example shows the method helloWorld(String)
that serves as a proxy to the helloWorld(String)
method in the associated Web Service implementation.
Example 6-2 shows client-side application code that uses the helloWorld()
method from the supplied client-side proxy shown in Example 6-1.
/** * Web service proxy: StatefulExample * generated by Oracle WSDL toolkit (Version: 1.0). */ public class StatefulExampleProxy { public java.lang.String helloWorld(java.lang.String param0) throws Exception { . . . } . . . }
import oracle.j2ee.ws_example.proxy.*; public class Client { public static void main(String[] argv) throws Exception { StatefulExampleProxy proxy = new StatefulExampleProxy(); System.out.println(proxy.helloWorld("Scott")); System.out.println(proxy.count()); System.out.println(proxy.count()); System.out.println(proxy.count()); } }
When you run a client-side application that uses Oracle9iAS Web Services, you can access secure Web Services by setting properties in the client application. Table 6-2 shows the available properties that provide credentials and other security information for Web Services clients.
In a Web Services client application, you can set the security properties shown in Table 6-2 as system properties by using the -D
flag at the Java command line, or you can also set security properties in the Java program by adding these properties to the system properties (use System.setProperties()
to add properties). In addition, the client side stubs include the _setTranportProperties
method that is a public method in the client proxy stubs. This method enables you to set the appropriate values for security properties by supplying a Properties
argument.
The Web Services WSDL allows you to manually, or using Oracle9i JDeveloper or another IDE, build client applications that use Web Services.
The Oracle9i JDeveloper IDE supports Oracle9iAS Web Services with WSDL features and provides unparalleled productivity for building end-to-end J2EE and integrated Web Services applications.
JDeveloper supports Oracle9iAS Web Services with the following features:
Non-Oracle Web Services IDEs or client development tools can use the supplied WSDL file to generate Web Services requests for services running under Oracle9iAS Web Services. Currently, many IDEs have the capability to create SOAP requests, given a WSDL description for the service.
|
Copyright © 2002 Oracle Corporation. All Rights Reserved. |
|