Creating a Web Service Client
See Also
A web service can be consumed in a web application, a Java application, or
a MIDP client (MIDlet). For information on consuming web services
in a MIDlet, see the J2ME Mobility documentation.
For JAX-WS clients, all imported WSDL files and schemas are
resolved automatically by the IDE. For JAX-RPC clients,
before you begin, note that if the WSDL file that you want to use imports schemas, other WSDL files, or both, from the local file system, the web service client will only work
if the imported schemas and WSDL files are copied beforehand into the WEB-INF/wsdl (or META-INF/wsdl)
folder. If you do not do this,
the Web Service Compiler
will not be able to locate these imported files at the end of the procedure below.
To create a web service client:
- Create the project to contain the web service client. Depending on how you want to
consume the web service, do one of the following:
- From the Projects window or Files window, right-click a node
in the project and choose New > File/Folder.
The New File wizard appears. Under Categories, select Web Services. Under File Types, select Web Service Client.
Click Next.
- Access the WSDL file of the web service that the web service client is to consume.
Depending on what the provider has distributed, do the following:
- To generate a client from a project
on your local filesystem, click Project and browse to a project's
web service port icon.
- To generate a client from a WSDL file
on your local filesystem, click Local File and browse to the WSDL file on
your local filesystem.
- To generate a client from a running web service, click WSDL URL,
then type or paste the web service's URL.
If you are behind a corporate firewall, click Proxy Settings and
set your proxy host and port number.
- The WSDL file is downloaded when you finish the wizard.
- Specify a package where the client files are to be generated. When you complete
the wizard, you can find the generated client files in the Files window, within the
build folder. See Exposing the Web Service Client in the Projects Window.
- For JAX-RPC (J2EE 1.4) clients, select the web service client type from the Client Type drop-down:
- J2EE Container-generated static stub.
This type is based on JSR-109, which enhances JSR-101 by defining the packaging
of web services into standard J2EE modules, including a new deployment descriptor,
and defining web services that are implemented as session beans or servlets.
This is the recommended and portable (via J2EE 1.4 specification) type.
When you choose this type, the IDE adds deployment information in the
deployment descriptors and the container generates the stub and other artifacts.
- IDE-generated static stub.
Only available for JAX-WS (J2EE 1.4) web services.
This type is based on JAX-RPC, which defines the mapping of WSDL to Java and vice versa.
It also defines a client API to invoke a remote web service and a runtime environment
on the server to host a web service. This type is not portable.
When you choose this type, the IDE generates
the stub and other
artifacts, packages them in the archive, and deploys them.
- If a web service is consumed in a Java application, no J2EE application server
is used. The application runs as a stand-alone JVM process and its
JVM parameters are set per project. Therefore, the J2EE Container-generated
static stub does not apply to Java applications and is not made available in the Client Type
drop-down.
For J2SE clients, use the JAX Version drop-down to
specify whether you want to create a JAX-WS client
or a JAX-RPC client.
- Click Finish.
- See Also
- About Web Service Clients
- About Web Services
Legal Notices