The web service wizard assists you in creating a skeleton
bean from an existing WSDL document. The skeleton bean contains a
set of methods that correspond to the operations described in the
WSDL document. When the bean is created, each method has a trivial
implementation that you replace by editing the bean.
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.
- Create or discover and import a WSDL document into a project.
You can only use a WSDL file that contains a service element.
Note: SOAP
over JMS web services are supported for WebSphere Application Server V8.0 or later;
however, support is not available for WebSphere Application Server Liberty
V8.5.5. If you want to use SOAP over JMS, your WSDL file must use
one of the following transport attribute URI values:
- http://www.w3.org/TR/soapjms/
- http://www.w3.org/2010/soapjms/
For more information about SOAP over JMS declarations in WSDL
files, refer to the specifications at:
SOAP over Java™ Message Service 1.0: Working
Draft
- Create an EJB project and add it to a new EAR project.
- Create an empty Web project if you are using SOAP over HTTP as
your transport methods, or an EJB project if you are using SOAP over
JMS as your transport method, to act as the router project. The project
you create must be added to the same EAR as the EJB project containing
the enterprise bean. For more information on router modules refer
to Creating router
modules.
- If you want to use SOAP over JMS, you must create a server and
server configuration for JMS as described in Create a server and
server configuration for SOAP over JMS.
About this task
To create a skeleton Java bean
from a WSDL document using the WebSphere JAX-WS
runtime environment:
Procedure
- Switch to the Java EE
perspective ( Window > Open Perspective > Java EE).
- In the Enterprise Explorer view, select the WSDL file you
have created or imported.
- Click File > New > Other. Select Web Services in
order to display the various Web service wizards. Select the Web
Service wizard. Click Next.
- Web Services page: select Top down EJB Web service as
your Web service type. You can optionally choose to do the following:
- Select the stages of Web services 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
or client gets associated to an EAR when required by the target application
server.
- Deploy: this will create the deployment code for the service.
- 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 service has been installed
on it.
- Test: this will provide various options for testing the service,
such as using the Generic Services Client, 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
server link and specify a different server.
- Select your runtime: the default runtime is displayed.
To deploy your service to the IBM® JAX-WS
runtime click the runtime link and select it in the window that opens.
This
task supports the following server runtime environments:
- WebSphere Application
Server V7.0 or later
- WebSphere Application Server Liberty V8.5.5
- Select the service project: the project selected in
your workspace is displayed. Only EJB projects are supported. To select
a different project and EAR click on the project link, or enter a
name and allow the wizard to create a project for you. 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.
- If you want to create a client, select the type of proxy
to be generated and repeat the steps for the client. The
client can be created later using the steps outlined in: Generating a web service client from a WSDL document using the IBM WebSphere JAX-WS runtime environment
- 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.
- Publish the Web service.
- WebSphere JAX-WS
Top Down EJB Web Service Configuration page:
- Output folder: Enter the location where the generated EJB skeleton
will be generated or accept the default.
- Target package: Enter the package name for the generated Java or accept the default.
- EJB Web service binding: select if your Web service will use HTTP
or JMS bindings.
- Enable wrapper style: Enables wrapper style mapping from WSDL
to Java. For WSDL documents
that implement a document/literal wrapped pattern, a root element
is declared in the XML schema and is used as an operation wrapper
for a message flow. Separate wrapper element definitions exist for
both the request and the response. More simply, the element whose
name is the same as the operation (the wrapper element) is broken
apart so that each of its content elements becomes a parameter of
the generated Java method signature.
- Enable MTOM support: If you select this check box the SOAP Message
Transmission Optimization Mechanism will be enabled to optimize the
transmission of binary content. For more information on MTOM refer
to: MTOM Overview
- Version of JAX-WS code to be generated: WebSphere Application Server V7.0, supports
JAX-WS 2.0 or 2.1 compliant code. WebSphere Application
Server V8.0, V8.5, and WebSphere(r) Application Server Liberty
V8.5.5, supports JAX-WS 2.0, 2.1, or 2.2 compliant code.
- Copy WSDL to project: Select this to copy the WSDL file into the
service project, or the required WSDL will be generated dynamically
by the runtime when needed. This is a convenient option if you plan
to create the client at a later time or publish the WSDL for other
users.
- Generate serializable JAXB classes: In WebSphere Application Server and WebSphere(r)
Application Server Liberty V8.5.5 when you enable the Java 6 facet, you can choose to
generate JAXB classes which implement java.io.Serializable. Classes
that do not implement this interface will not have any of their state
serialized or deserialized.
- 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. If this is selected the next page of the
wizard will allow you to browse to the custom binding declaration
files.
- Customize service implementation class name: Select this check
box if you want to change the default port name to service implementation
class name mapping.
- Generate schema library: this allows you to generate schema code
into a schema library. If you select a schema library, on a later
page you can customize the mappings between XSD documents or groups
of XSD documents to a project.
- 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.
- Depending on the options chosen on the previous page, you
may be prompted to customize your Web service implementation on the
following pages:
- WebSphere JAX-WS
JMS Binding Configuration page: if you selected for your Web service
to use JMS as its transport method, you will need to enter information
about the binding on this page.
- JMS destination: Select either queue or topic as your destination
type.
- Destination JNDI name: The JNDI name of the destination queue
or topic.
- JMS connection factory: The JNDI name of the connection factory.
- Initial context factory name: The name of the initial context
factory to use. This is mapped to the java.naming.factory.initial
property.
- JNDI provider URL: This is mapped to the java.naming.provider.url
property.
- Delivery mode: Indicates whether the request message should be
persistent or not.
- Request message lifetime: The lifetime in milliseconds of the
request message. A value of 0 indicates an infinite lifetime.
- JMS request message priority: The JMS priority associated with
the request message. 0 is the lowest priority and 9 is the highest
priority.
- Reply to name: The name of the port component to which the request
will be dispatched.
- Connection factory user ID: The user ID to be used to gain access
to the connection factory.
- Connection factory password: The password to be used to gain access
to the connection factory.
- Use SOAP/JMS interoperability protocol: Selecting this ensures
that the Web service complies with the protocol outlined by the W3C
SOAP-JMS Binding Working Group. For more information refer to this
site: Charter of the SOAP-JMS Binding Working Group
- Define custom JMS properties: Selecting this will launch a page
enabling you to enter property value pairs.
- Custom Binding Declarations page: If you have selected
to specify JAX-WS or JAXB binding files you can browse to the files
on this page.
- Service Implementation Configuration page: For each
port defined in the WSDL file, you can enter a name for the service
implementation class or accept the default.
- Schema project configuration page: If you selected to
generate a schema library use this page to customize the mappings
between XSD documents and projects. This feature will only work if
all the schema dependencies are in different targetNamespaces; otherwise
there will be compilation errors in ObjectFactory.java.
- WebSphere JAX-WS
Router Project Configuration page: This page displays
when targeting WebSphere Application
Server runtime environment, but not WebSphere Application Server Liberty
V8.5.5.
- HTTP router: enter the name of the project you want used as the
router module. A router module provides a Web service endpoint for
a particular transport.
- JMS router: enter the name of the project you want used as the
router module. A router module provides a Web service endpoint for
a particular transport.
- MDB deployment mechanism: select from the JMS activation spec
or the listener port as your message-driven bean deployment mechanism.
- ActivationSpec JNDI name: type the JNDI name of the activation
specification that is to be used to deploy this message-driven bean.
This name must match the name of an activation specification that
you define to WebSphere Application
Server
- Listener input port name: enter the listener port name of the
router module.
- Test Web Service page: If you selected to test the web
service from step 4a, select the test facility for the generated web
service and click Launch. This will open the
web service in the Web Services Explorer or Generic Services Client.
Note that you can only use the Web Services Explorer to test web services
which use HTTP transports. Select the operation you want to test,
enter the required information, and click Go. The result will
display in the Status pane. Click Next.
- WebSphere JAX-WS
Web Services Client Configuration page: if you have selected to generate
a client, you can specify the following options for it on this page:
- Output folder: This is the location where the client code will
be generated
- Target package: The web services client wizard generates a number
of Java files. 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.
- 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 or WebSphere(r) Application Server Liberty V8.5.5 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 are 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 the web service client. If this is selected the next page of
the wizard will allow you to browse to the custom binding declaration
files.
- Customize client proxy class name: Select this check box if you
want to change the default port name to service implementation class
name mapping
- 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.
- Version of JAX-WS code to be generated: For WebSphere Application Server V7.0, you
have the option of generating JAX-WS 2.0 or 2.1 compliant code. For WebSphere Application Server
V8.0, V8.5, and WebSphere Application
Server Liberty V8.5.5, you have the option of generating
JAX-WS 2.0, 2.1, or 2.2 compliant code.
- Custom Binding Declarations page: If you have selected
to specify JAX-WS or JAXB binding files you can browse to the files
on this page.
- Service implementation configuration page: Proxy Generation
Configuration page: For each port defined, you can enter a name for
the proxy class or accept the default.
- 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
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 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.
Results
After the web service has been created, the following may
occur depending on the options you selected:
- The implementation bean will be opened in the Java editor. This contains skeleton code that
can be used to test the basic function of the web service, or you
can implement the required business logic for your service before
testing it.
- 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. Since this
is a Java bean skeleton with
trivial method implementation, a value of -3 will be returned.
- 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.
- 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.