|
|
Web services are increasingly seen as the core technology of the
future for developing IT solutions capable of crossing the
traditional borders of implementation technology, OS and hosting
environment, and intra-enterprise and inter-enterprise business
domains. This document presents an overview of the MyEclipse web
services development features which include tools for rapidly
developing and testing web services and a light-weight deployable
web services container. Key web services development features
include:
-
Top-down and bottom-up web service creation tools
-
Web Service Explorer for testing web services
-
WSDL creation, editing and validation tool, including JSR-181 WS
annotations
-
Web service project creation, configuration and validation
-
Deploy web services to any Java servlet 2.4+ container
-
Debug Java web service implementations
MyEclipse web services tools are designed to work with the
open-source
XFire Java SOAP engine.
XFire is one of the few and most popular vendor independent SOAP
engines. Key XFire features include:
-
Web Service standards: SOAP, WSDL, WS-I Basic Profile,
WS-Addressing, WS-Security, JSR-181 WS annotations
-
Java-XML binding technology: Aegis, JAXB2 & 1, XMLBeans,
Castor, and JIBX
-
Multiple transport support: HTTP, JMS, XMPP, in-memory
-
High performance SOAP stack
|
|
|
The first step in developing a web service is to create a
MyEclipse web service project. This type of project is an
extended web project that is fully deployable to any servlet 2.4
or greater container. There are two methods for creating
MyEclipse web service projects are described below.
The simplest way to create a web service project is to launch the
MyEclipse Web Service Project Wizard from the toolbar menu.
Figure 2.1.1. Launching the Web Services Project Wizard
Figure 2.1.2. Project details page of the web services wizard
Figure 2.1.3. Deployment details page of the web services wizard
Figure 2.1.4. Library configuration page of the web services
wizard
Figure 2.1.5. Package explorer view of a new web service project
Figure 2.1.6. View of web.xml configuration for a web services
project
In addition to creating a Web Service Project directly, you can
also enable any MyEclipse web project to host web services by
adding Web Service Capabilities to that project. The web service
capabilities wizard is very similar to the web services project
wizard and can be launched from the
MyEclipse>Capabilities>Add XFire Web Service Capabilities...
menu.
Figure 2.2.1. Launching the Web Service Capabilities Wizard
MyEclipse-XFire libraries simplify the build-path management of
XFire JARs. The libraries are organized around XFire features.
Thus you can pick and choose the XFire features that you wish to
support with in your project by adding or removing the
feature-specific MyEclipse-XFire libraries.
Figure 2.3.1. MyEclipse XFire libraries that can be added to a
web service project
2.4 Web Service Project Preferences
The MyEclipse web service preferences enable you to configure the
JAR contents of the MyEclipse-XFire libraries. To access this
preference page, from the workbench menubar select
Window > Preferences > MyEclipse > Project
Capabilities > Web Services.
Figure 2.4.1. Web services library preference page
|
|
The MyEclipse Web Service Wizard supports the bottom-up web
service development process. This process concentrates initial
development effort towards the creation of application business
logic in the form of Java beans (POJOs) prior to defining the web
service interfaces (WSDL). The wizard supports creation of web
services from existing Java beans or will generate new Java beans
if instructed.
Launch the web service wizard from the MyEclipse Java Enterprise
perspective toolbar.
Figure 3.1. Launching the Web Service Wizard
Select the MyEclipse web service project in which the new web
service will be created and the Bottom-up scenario option.
Figure 3.2. Bottom-up page of web service wizard
Enter the new web service name and implementation details. Select
Finish to create the web service.
Figure 3.3. Web service details page of the web service
wizard
Upon completion the wizard has created the Java interface,
IHelloWorldService, the Java class, HelloWorldServiceImpl, and
added a <service> entry in the XFire services.xml
deployment descriptor.
Figure 3.4. Newly created web service and updated services.xml
deployment descriptor
|
|
The MyEclipse Web Service Wizard also supports the Top-down web
service development process. This process concentrates initial
development effort towards the definition of web service
interfaces in the form of WSDL prior to the web service
implementation.
Figure 4.1. Bottom-up page of web service wizard
Specify the WSDL file location, the Java-XML binding to generate,
and the Java source folder and package where web service skeleton
will be generated. Select Finish to complete the wizard.
Figure 4.2. Web service details page of the web service
wizard
Upon completion the wizard has added a <service> entry to
the services.xml file and generated the Java-XML binding classes,
the HelloWorldServicePortType interface, the
HelloWorldServiceImpl class and the HellowWorldServiceClient
class. Note that the project's compiler compatibility settings
must be set to Java5 or greater as the generated Java code
includes Java 5 - JSR-181 annotations.
Figure 4.3. Newly created Top-down web service
4.1 WSDL Validation
WSDL files used by the Top-down Service Wizard and the New Web
Service Client wizard are now validated before the code
generation process. WSDL validity and WS-I compliance are
checked, giving you the opportunity to correct any mistakes
before generating code.
Figure 4.1.1. WSDL validation results in Top-down web
services wizard
4.2 Web Services Basic-I Profile Validation
Web Services Basic-I Profile (WS-I) is a web services
interoperability standard that defines the technologies, their
specification levels and restrictions to form a common
interoperable web service platform. MyEclipse web services tools
can be enabled to validate web service projects for conformance
with the WS-I specification.
Figure 4.2.1. WS-I validation configuration preferences
|
|
MyEclipse enables the Java Editor to support JSR-181 annotations.
The Java Editor will immediately recognize web service
annotations for MyEclipse web service projects.
Figure 5.1. Code assistance with JSR-181 annotations in
Java editor
|
6. WSDL Creation and Editing
The WSDL File Wizard will create a skeleton WSDL file. To launch
the wizard, select
File>New>Other>MyEclipse>Web Services>WSDL.
Figure 6.1. Launching WSDL Creation Wizard
Enter the namespace and select "Create WSDL Skeleton".
Select Finish to complete the wizard and generate the file.
Figure 6.2. WSDL details page of WSDL Creation Wizard
Upon completion the skeleton WSDL file is created and opened in
the MyEclipse XML editor for review and revision.
Figure 6.3. WSDL Editor
|
7. Importing Web Services and WSIL Files
Use the MyEclipse Web Service Import Wizard to import WSDL and
WSIL files into your project.
Figure 7.1. Launching the WSDL Import Wizard
|
8. Web Service Client Development
Convenient actions allow you to create a new Web Service client
or a new Web Service directly from a WSDL file.
Figure 8.1. Launching the Web Services Client Wizard
Figure 8.2. Details page of Web service client wizard
|
9. Web Service Project Deployment and Debugging
A MyEclipse web service project can be deployed to any J2EE 1.4
or Java EE 5 servlet container. During the deployment process
MyEclipse dynamically packages a project's web service resources
and the XFire engine into a fully debuggable web archive
(WAR). The deployment services are able to package and
publish the web service project in both exploded archive form for
development time debugging and in packaged archive form for
production time distribution. The deployment service provides
hot-sync update of all modified Java and web resources of a web
service project to all of its exploded deployments.
Figure 9.1. Deployed web services project depicted in
Servers
9.1 Web Service Deployment Descriptor Editor
The XFire framework is configured by services.xml deployment
descriptor file. This file is a Spring beans XML configuration
file that utilizes
XBean customizations. The
MyEclipse XFire Deployment Descriptor Editor extends the
MyEclipse XML Editor with grammar-based code-assistance and
validation using an implicit special XFire DTD, custom
code-assist for XML elements that define Java classes and
interfaces.
Figure 9.1.1. Web Services Deployment Descriptor Editor
Once deployed, standard MyEclipse web debugging facilities are
available to all web services projects. These include hot-swap
Java debugging and hot-sync JSP and JavaScript debugging.
Figure 9.2.1. Debugging a web service implementation
|
10. Testing with the Web Service Explorer
MyEclipse web services tools include the Web Service Explorer for
dynamically interacting with local and remote web services.
All you need is access to the WSDL document that defines the web
service interface. The Web Service Explorer reads a WSDL document
for the service you wish to interact with and generates a dynamic
interface that allows you to send SOAP requests and view
corresponding SOAP responses.
Launch the Web Services Explorer from the MyEclipse perspective
toolbar.
Figure 10.1. Launching the Web Services Explorer
Select the WSDL mode and enter the path to the WSDL file. In the
example below we used the URL
http://localhost:8080/HelloWorld/services/HelloWorldService?WSDL.
Once the WSDL is retrieved the Web Service Explorer will present
a list of end points. Below you can see the "example"
operation is exposed and has 1 input parameter named in0. When
the Go button is pressed, a SOAP request is constructed to invoke
the "example" operation and the string
"helloworld" is bound to the in0 parameter in the
request. The result of the operation is displayed in the Status
pane.
Figure 10.2. Exploring your web service
|
|
We would like to hear from you! If you liked this overview, have
some suggestions or even some corrections for us please let us
know. We track all user feedback about our learning material in
our
Documentation Forum.
Please be sure to let us know which piece of MyEclipse material
you are commenting on so we can quickly pinpoint any issues that
arise.
|