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:
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).
- In the Enterprise Explorer view, select the Web project
in which you want to generate a sample application.
- 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. 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.
- 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 service project: the project containing the
project selected in your workspace is displayed. To select a different
project and EAR click on the project link. 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.
- 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.
- web service Proxy page: This page shows the options for
the proxy. It lists the folder where the proxy will be generated,
and you can optionally enable security for the proxy, and create custom
mappings between namespaces and packages. Click Next.
- web service Client Namespace to Package Mappings page:
if you selected Define custom mapping for namespace to
package on the previous page, you can enter your custom
mapping pairs on this page by clicking Add.
Alternately, you can click Import to import custom mapping
pairs from a .properties file. The content
of the properties file must be of the format namespace=package. You will need to escape some special characters in the properties
files. For example http://someNamespace=somePackage should
be http\://someNamespace=somePackage. Otherwise,
the colon (:) would be treated as delimiter resulting in trying to
map http to //someNamespace=somePackage.
For more information about formats for properties files in Java, refer to: Java Platform
API documentation: java.util.Properties load method.
- web service Client Test page: Select the test facility
that you will use to test the proxy, and the methods that you want
included in the proxy. 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. Click Next.
- 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 or the Universal test client.
- If you have selected to test the generated proxy using web service
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 the following
URL: http://localhost:9080/UTC/preload?object= BeanPackage. BeanServiceProxy.
In the Reference pane, under Object References, 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.
For more information on creating a Web project, refer to the
Web application development documentation.