The web service client wizard assists you in generating
a Java™ bean proxy and a sample
application. The sample web application demonstrates how to code a
proxy file.
Before you begin
Prerequisites:
- If you are using WebSphere® Application Server, it is strongly
suggested that you start the server before running the web service
wizard because it may take several minutes to start the WebSphere Application Server depending
on the speed of your computer. To start the server, select it in the
Servers view (Window > Show View > Servers),
right-click and select Start.
- Discover or import a WSDL document into the workspace. You can
use a WSDL file that contains a service element. You can use a static
WSDL file from your workspace, a WSDL file that resides at a URL,
or if you have an annotated bean that acts as a JAX-WS web service
in your workspace, the WSDL file dynamically produced by the WebSphere Application Server
Feature Pack for Web Services run time. This WSDL can be found at
the URL: http://localhost:port/service_project_name/service_nameService?wsdl.
For example, in the address book JAX-WS web service that is created
in the tutorial and samples that accompany the Feature Pack for Web
Services the dynamic WSDL file would be found at this URL: http://localhost:9082/jwsAddressBook/AddressBookService?wsdl.
Restriction: If the you want to run a simple Java web service client outside
of any J2EE container, you must generate the web service client into
a simple Java project. The web
service wizard cannot create a simple Java project.
The closest form is an utility project, however running a simple Java web service client (containerless)
from an utility project is not supported. You must create a simple Java project before running the
web service client wizard. The JDK Compiler compliance level for the
simple Java project must be set to the Java version on which the WebSphere
Application Server runs.
About this task
To generate a Java client
proxy and a sample application from a discovered WSDL document:
Procedure
- Switch to the Java EE
perspective (Window > Open Perspective > Java EE).
- Click File > New > Other. Select Web Services to
display the various web service wizards. Select the Web Service
Client wizard. Click Next.
- Web Services page: select the WSDL file that you use to
generate the client. You can optionally choose to do the following:
- Select the stages of web service client development
that you want to complete by using the slider. This sets several default
values on the remaining wizard panels.
- Develop: develops the WSDL definition and implementation of the
web service client. This includes such tasks as creating the modules,
which contain the generated code, WSDL files, deployment descriptors,
and Java files when appropriate.
- Assemble: ensures the project that hosts the web service client
gets associated to an EAR when required by the target application
server.
- Deploy: creates the deployment code for the client.
- Install: installs and configure the web module and EARs on the
target server. If any changes to the endpoints of the WSDL file are
required, they are made in this stage.
- Start: starts the server once the client has been installed on
it.
- Test: provides various options for testing the service, such as
using the Web Service Explorer or sample JSPs.
- Select your server: the default server is displayed.
If you want to deploy your service to a different server click the
link to specify a different server.
This
task supports the following server runtime environments:
- WebSphere Application
Server V7.0 or later
- WebSphere Application Server Liberty V8.5.5
- Select your runtime: the default runtime is displayed.
If you want to deploy your service to a different runtime click the
link to specify a different runtime.
- Select the client project: the project that is selected
in your workspace is displayed. To select a different project and
EAR click the project link. You can select a web project,
an EJB project, a Java project,
or a Java EE application client
project as the location for the client code. Ensure that the project
selected as the Client Web Project is different from the Service Web
Project, or the service is overwritten by the client's generated artifacts.
For JAX-WS web services, the server and client projects can share
the same EAR.
- Monitor the web service: sends the web service traffic
through the TCP/IP Monitor, which enables you to watch the SOAP traffic
that is generated by the web service and to test this traffic for
WS-I compliance. Alternately you can manually set up a TCP/IP monitor
as described in Using the TCP/IP Monitor to test web services.
- WebSphere JAX-WS
Web Service Client Configuration page:
- Output folder: Select the folder where you want the client's Java classes to be generated or
accept the default.
- Target package: The web services client wizard generates a number
of Java files from the specified
WSDL. By default it creates a package name that is based on the namespace
that is specified in the WSDL file. To override this default behavior,
you can specify your own package name for the namespace in the WSDL
file.
- Generate portable client: Selecting this check box would enable
you to move your web service client code from one machine to another
or from one instance of WebSphere Application
Server to another. If this option is selected, the WSDL document and
all the XML schema and other WSDL documents that it depends upon is
copied into the client project under WEB-INF/wsdl and a file:relativeURL pointing
to this copy is then iinjected into the JAX-WS Service class's
static initialization block.
- Enable asynchronous invocation for generated client: If you select
to enable an asynchronous client, for each method in the web service
two more methods are created. These methods are polling and callback
methods, which allow the client to function asynchronously.
- Specify JAX-WS or JAXB binding files: If you created JAX-WS or
JAXB custom binding files, select this check box to use them to create
this web service.
- Customize client proxy class name: You can accept the default
proxy name or enter your own.
- Generate web service deployment descriptor: For JAX-WS web services
deployment information is generated dynamically by the runtime; static
deployment descriptors are no longer required. Selecting this check
box generates them.
- Allow vendor extensions: If you select this check
box, the -extension option is added to the wsgen or wsimport command.
The -extension option specifies whether to enable
or accept custom extensions for functionality not specified by the
JAX-WS specification. Use of the extensions can result in applications
that are not portable or do not interoperate with other implementations.
For details, see wsgen command for JAX-WS applications and wsimport command for JAX-WS applications topics
available in the Information Center for WebSphere Application Server.
- Custom binding declaration page: If you selected
to supply a JAX-WS or JAXB binding file on the previous page, you
can browse to where they are located.
- Proxy generation configuration page: If you
selected to customize the client proxy class name, use this page to
specify a proxy class name for each port.
- Web Service Client Test page:
- Test the generated proxy: If selected, the sample client is launched
in a web browser which enables you to test the function.
- Select your test facility. You can test the generated proxy in the
Generic Service Client or the Web Service Explorer, or you can generate
and use the sample JAX-WS 2.0 JSPs.
- Folder: If you selected to test the proxy through a JSP, you can
select the folder where the JSP is located, and you can select the
methods that are included in the JSP.
- Methods: Select the methods to expose. If you selected to enable
asynchronous invocation, the asynchronous methods should be listed
as well.
- Run test on server: starts the server for you automatically.
- Click Finish. If you selected to test the proxy,
the test client opens in a browser window.
Results
The generated Java bean
proxy provides a remote procedure call interface to the web service.
The sample Web application demonstrates how to code the proxy file.
Once you have generated your Java client proxy, you may test the methods
of the web service through the proxy using web services sample JSPs,
or the Web Services Explorer.
- If you selected to test the web service by using the Web Services
Explorer, the Explorer opens. Select the operation that you want to
test, enter the required information, and click Go. The result
displays in the Status pane.
- If you selected to test a Java thin
client, the system output of running your Java thin client is shown in the Console view.
You can run the Java thin client
by clicking Run in the Run Configurations dialog
box. As a plain Java application,
the client uses a corresponding WebSphere Application
Server thin client runtime container JAR.