Relief in mind

Wednesday, January 11, 2006

Steps for creating a WS with AXIS

1. Create the interface for your application.
2. Create the Impl of your Intf.
3. Compile Intf and Impl
4. Java2WSDL : Generate WSDL for the given Interface
  • Name of output WSDL (mailSender.wsdl)
  • URL of the Web service (http://localhost:8080/axis/services/mailSender)
  • Target namespace for the WSDL (urn:mailSender)
  • Map Java package = namespace (mailSender = urn:mailSender)
  • Fully qualified class itself (com.usta.mail.MailSender)

The full command for our example becomes something like:

% java org.apache.axis.wsdl.Java2WSDL -o mailSender.w
sdl -l"http://localhost:8080/axis/services/mailSender" -n urn:mailSender -p"mail
Sender" urn:mailSender com.usta.mail.MailSender

mailSender.wsdl is generated after the execution

5. WSDL2Java : Generate the Server-Side Wrapper Code and Stubs for Easy Client Access
  • Base output directory (.)
  • Scope of deployment (Application, Request, or Session)
  • Turn on server-side generation (we wouldn't do this if we were accessing an external Web service, as we would then just need the client stub)
  • Package to place code (
  • Name of WSDL file (mailSender.wsdl)

The full command for our example becomes something like:

% java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -p mailSender.wsdl

After running this program, following codes have been generated in the fibonacci\ws directory:

  • This is the implementation code for our Web service. This is the one file we will need to edit, tying it to our existing FibonacciImpl.
  • This is a remote interface to the Fibonacci system (extends Remote, and methods from the original throw RemoteExceptions).
  • Service interface of the Web services. The ServiceLocator implements this interface.
  • Helper factory for retrieving a handle to the service.
  • Server-side skeleton code.
  • Client-side stub code that encapsulates client access.
  • deploy.wsdd: Deployment descriptor that we pass to the Axis system to deploy these Web services.
  • undeploy.wsdd: Deployment descriptor that will undeploy the Web services from the Axis system.
6. SMailSenderSoapBindingImpl : Fill in wrapper to call the existing code
7. Deploy the service to Apache Axis
Compile ws java files
package ws, and app classes : jar cvf mailer.jar com/usta/mail/*.class com/usta/mail/ws/*.class
Copy jar file under TOMCAT_HOME/webapps/axis/WEB-INF/lib
Deploy the web service : java org.apache.axis.client.AdminClient deploy.wsdd
8. Write a client that uses the generated stubs to easily access the web service
In the code get access to the service via the ServiceLocator, and then call methods on the remote handle that we have in order to use the service.



Post a Comment

<< Home