Creating a Web Service from a WSDL File
See Also
When you and your business partners agree on a "contract" in the form of a WSDL file,
you can use the IDE to implement it. The WSDL file is an agreement on the data and messages
that will be exchanged as well as how these messages will be sent and received.
In the IDE, you can use the WSDL file to implement the web service.
Business requirements may demand that you create a platform-independent
description of a web service as a set of XML schema files and WSDL files. Based on this
platform-independent description, you can use the steps that follow to generate
the implementation files. The WSDL file that you use in the steps below can either be
available on disk or via a URL. You can even create the WSDL file yourself, using the IDE,
as described in Creating a WSDL File.
-
For J2EE 1.4 web services, if the WSDL file imports schemas, other WSDL files, or both, from the local file system, the web service 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 from a WSDL file:
- Depending on the implementation form, do one of the following:
- In the Projects window or Files window, right-click the project node
and choose New > File/Folder. In the Web Services folder, choose
Web Service from WSDL.
The New Web Service from WSDL wizard opens.
- Type the web service name and specify a package to house the web service.
- Browse to a WSDL file on your filesystem.
- Click Finish.
For JAX-WS web services (Java EE 5 specification), the IDE runs the wsimport tool, which results in the following:
- A WSDL file file is consumed, created by the IDE. The abstract portion is copied as is from the original file,
while the concrete portion is "normalized" from the original.
See About the WSDL File for abstract and concrete definitions in the WSDL file.
For example, a SOAP binding element is created if it did
not exist in the WSDL file. Also, the abstract service element is created to be compatible with
the binding.
- An implementation class. The operations found
in the WSDL file are added to this class.
For JAX-RPC web services (J2EE 1.4 specification), the IDE runs the wscompile tool, which results inS the following:
- A new WSDL file. The abstract portion is copied as is from the original file,
while the concrete portion is "normalized" from the original.
See About the WSDL File for abstract and concrete definitions in the WSDL file.
For example, a SOAP binding element is created if it did
not exist in the WSDL file. Also, the service element is created to be compatible with
the binding.
- A Service Endpoint Interface (the "interface"), which declares the web service's operations.
In the IDE, the interface class is identified by the name of the
portType element defined in the WSDL.
The IDE automatically populates the interface with a declaration for each web service operation
from the WSDL file.
- An implementation class. The operations found
in the WSDL file are added to this class. In the IDE, a JAX-WS class is
identified by the name that you specify in the wizard.
In the IDE, a JAX-RPC implementation class is identified by the name of the
portType element defined in the WSDL together with the suffix "_Impl" (for web applications)
or "_Bean" (for EJB modules).
By default, the WSDL file is housed in the WEB-INF/wsdl (or META-INF/wsdl) folder. The
interface and the implementation class are housed in a package within your project's src folder (in the Files window)
and you can access them in the Source Packages node (in the Projects window).
- You cannot add operations to a web service created from a WSDL file.
- See Also
- About Web Services
- About Implementing Web Services
- Creating a Web Service from Java
- Creating a WSDL File
Legal Notices