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
only use a WSDL file that contains a service element. You can use
a static WSDL file from your workspace, a WSDL file residing at a
URL, or if you have an annotated bean acting as a JAX-WS web service
in your workspace, the WSDL file dynamically produced by the WebSphere Application Server
Feature Pack for Web Services runtime. 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 created in the
tutorial and samples accompanying 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 in
order to display the various web service wizards. Select the Web
Service Client wizard. Click Next.
- Web Services page: select the WSDL file that you will
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 using the slider. This will set several
default values on the remaining wizard panels.
- Develop: this will develop the WSDL definition and implementation
of the web service client. This includes such tasks as creating the
modules which will contain the generated code, WSDL files, deployment
descriptors, and Java files
when appropriate.
- Assemble: this ensures the project that will host the web service
client gets associated to an EAR when required by the target application
server.
- Deploy: this will create the deployment code for the client.
- Install: this will install and configure the Web module and EARs
on the target server. If any changes to the endpoints of the WSDL
file are required they will be made in this stage.
- Start: this will start the server once the client has been installed
on it.
- Test: this will provide 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 Profile 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 selected in your
workspace is displayed. To select a different project and EAR click
on 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 will be 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: this will send the web service
traffic through the TCP/IP Monitor, which allows you to watch the
SOAP traffic 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. Note that if you are routing web service traffic through the
TCP/IP monitor that you cannot test the web service using the Universal
Test Client.
- 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 will create a package name based on the namespace
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 checkbox would allow
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 will
be copied into the client project under WEB-INF/wsdl and a file:relativeURL pointing
to this copy will then be injected 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 additional methods will be created. These are polling and callback
methods which allow the client to function asynchronously.
- Specify JAX-WS or JAXB binding files: If you have 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 checkbox
will generate 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 will
be launched in a Web browser enabling you to test the functionality.
- Select your test facility. You can test the generated proxy in
the Universal Test Client or the Web Service Explorer, or you can
generate sample JAX-WS 2.0 JSPs. Note that if you are routing web
service traffic through the TCP/IP monitor that you cannot test the
web service using the Universal Test Client.
- Folder: If you selected to test the proxy through a JSP, you can
select the folder where the JSP will be located, and you can select
the methods that will be 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: this will start the server for you automatically.
- Click Finish. If you have selected to test the
proxy, the test client will open 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, the Universal test client, or the
Web Services Explorer.
- If you have selected to test the generated proxy using JAX-WS
2.0 JSPs, the proxy is launched in a Web browser at the following
URL: http://localhost:port/WebProjectClient/sampleBeanName/WebServiceName/TestClient.jsp You
can use this sample application to test the web service by selecting
a method, entering a value for the method, and clicking Invoke.
The result of the method will display in the results pane.
- If you have selected to test the generated proxy using the Universal
Test Client, it will be launched in a browser window at a URL similar
to the following: http://localhost:port/UTC/preload?object=BeanPackage.BeanServiceProxy.
Under Objects, expand the proxy stub to display the methods of the
web service. Click the method you want to test, enter a value in the
Parameters pane, and click Invoke. The result
will be generated below.
- If you have selected to test the web service using the Web Services
Explorer, the Explorer will open. Select the operation you want to
test, enter the required information, and click Go. The result
will display in the Status pane.
- If you had 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 WAS thin client
runtime container JAR.