Developing Axis based Web Services
Download
Report
Transcript Developing Axis based Web Services
Developing Axis based Web
Services using Eclipse 3.3
Saurabh Mittal
Feb 28, 2008
Preparing the platform
• Using Eclipse
– Download Java EE version from
http://www.eclipse.org/downloads/
– It contains WST plugin that contains Axis 1.4 platform
– Install at root, e.g. C: etc.
– Create workspace at c:\workspace
• Using Apache Tomcat server (5.5+)
– Download binary distribution (Core) at:
http://tomcat.apache.org/download-60.cgi
– Container to host services as .war and .ear
– Install at default directories
Project Development
• Client and Server are developed independently
– In fact, are used differently
• An Example like Chat Service
• We will develop
– Chat Server
• Developing/generating WSDL
– Chat Client
Server-side Development
•
Create a Dynamic Web Project (put name
676ChatCollaboration)
–
–
•
Ensure you select target runtime as Apache Tomcat
5.5+
Fall through and click Finish
Develop the software model and software
engine (recall MVC paradigm)
–
–
We are using MC here.
Other enterprise implementation like servlets etc.
use V towards browser based functionalities using
JSP, DHTML, .cgi etc.
Software Model: server
• Create a pacakge to hold ‘model’ such as:
edu.acims.models.
– Create ChatPerson
– Create ChatMessage
– Create other classes
• Remember that it is an implementation of a
‘model’.
– Recall your software engineering principles.
– A UML class diagram is the closest that can be
translated to code here
Model Control: server
• Develop the engine control to access the ‘model’
and use the model
• Your engine is analogous to a UML collaboration
or a sequence diagram
• Before you begin development of engine,
ENSURE that you have an INTERFACE that
accesses the Model
– Helps keep the design separated from the
implementation
– E.g package edu.acims.services, ChatEngine.java
Service Design: server
• Use the engine that you developed
– use Interfaces ONLY to connect Model and
engine
– Keep it clean and simple
– Use your design patterns in creating effective
interfaces that enhance model reuse
– Develop a separate class that use the engine.
• It is this class that you will make public and expose
as Service
• E.g. ChatService.java in edu.acims.services
Generating Service: server
• Using the bottom-up approach
– From java code to Web service artifacts like .wsdl
– Right Click on java-class and select Create Web
Service
– Move the slider to ‘Assemble Service’
– No need to generate client using wizard
• But you can explore…it’s a good means
• We will use it soon
– Select functions to expose as ‘service methods’
– Make sure you have empty constructors in your
Models
– Select document/literal (wrapped) as default method
Making it deployable: server
• Ensure that the project has WebContent folder
populated with the generated wsdl
• WEB-INF will contain the generated deployment
descriptor
• You need to export the entire web project as .war
• Right click on project node and click ‘Export as”
.war
• Save
• Put it in Tomcat/webapps directory. Stop and
Restart
• Your service is deployed…
Developing CLIENT
• We will start with the web service definition
from WSDL
• Client treats web service as a black-box
with WSDL as only means to access the
black box
• Create an empty java project
• Create a folder and copy-paste .wsdl file
from the project you just completed
Generating Web service Client
• Right click on .wsdl and Click Web Services and
Generate Client
• Use Assemble Client option
• Click finish
• You will see the generated code in src folder
• Our interest is in the class that ends with
Proxy.java as it provides the usable code to use
in our desired client functionality
– See the implementation in GPanelChatClient.java that
use these proxy methods and render them using GUI