Oracle9i Application Server Web Services Developer's Guide Release 2 (9.0.3) Part Number B10004-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 10, "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.
This section covers the following:
To use Oracle9iAS Web Services you need to create a client-side application that accesses a Web Service. Oracle9iAS Web Services supplies the following files for deployed Web Services:
Oracle9iAS Web Services provides a Web Service Home Page for each deployed Web Service. To access a Home Page, enter a service endpoint of the form,
http://host:port/context-root/service
Figure 8-1 shows the Web Service Home Page for StatefulExample, at the following endpoint,
http://system1.us.oracle.com/webservices/statefulTest
A Web Service Home Page provides the following:
Web Service Test Pages have the following limitations:
If you do not use the Web Service Home Page to get the WSDL file or client-side proxy for a Web Service, you can obtain these files directly.
This section covers the following:
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 8-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 8-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 8-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 8-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 8-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_proxysrc.jar
is a Jar file that contains the client-side source files for the client-side proxy that accesses the Web Service.
The Oracle9iAS Web Services WebServicesAssembler
tool allows you to generate client-side proxies. A client-side proxy can access a Web Service that is deployed either on an Oracle9iAS Web Services endpoint or on a third party Web Service endpoint.
To generate a client-side proxy with WebServicesAssembler
, specify a <proxy-gen>
tag in the configuration file. Table 8-2 describes the <proxy-gen>
WebServicesAssembler
configuration file sub-tags.
Note:
When you are generating client-side proxies and you are accessing an external WSDL file from behind a firewall, make sure to set the appropriate security properties shown in Table 8-3, such as |
Example 8-1 shows a sample WebServicesAssembler
that includes a <proxy-gen>
tag.
<?xml version="1.0"?> <web-service> <proxy-gen> <proxy-dir>/TestArea/Hotel/proxy/outside</proxy-dir> <option name="include-source">true</option> <option name="wsdl-location" package-name="myPackage.proxy"> http://terraservice.net/TerraService.asmx?WSDL</option> <option name="wsdl-location"> http://ws.serviceobjects.net/sq/FastQuote.asmx?WSDL</option> </proxy-gen> </web-service>
This section describes how to use the client-side proxy Jar when you are building the client-side application to access a Web Service. The client-side proxy Jar class allows you to easily build an application that uses a Web Service.
The client side proxy Jar file contains a Java class to serve as a proxy to the Web Service implementation. 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 8-2 shows a source code sample client-side proxy extracted from a Web Service. For each operation 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 8-3 shows client-side application code that uses the helloWorld()
method from the supplied client-side proxy shown in Example 8-2.
Note:
When you are accessing an external Web Service from behind a firewall, make sure to set the appropriate security properties shown in Table 8-3, such as |
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 Java Beans are used as parameters to Oracle9iAS Web Services, the client-side code should use the generated Bean included with the downloaded client-side proxy. This is because the generated client-side proxy code translates Simple Object Access Protocol (SOAP) structures to and from Java Beans by translating SOAP structure namespaces to and from fully qualified Bean class names. If a Bean with the specified name does not exist in the specified package, the generated client code will fail.
However, there is no special requirement for clients using Web Services Description Language (WSDL) to form calls to Oracle9iAS Web Services, rather than the client-side proxy. The generated WSDL document describes SOAP structures in a standard way. Application development environments, such as JDeveloper, which work directly from WSDL documents can correctly call Oracle9iAS Web Services with Java Beans as parameters.
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 8-3 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 8-3 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. |
|