20 May 2015

Introduction

This blog will help you to

  • write a SOAP webservice and deploy on tomcat server.
  • write a client to call the webservices

Required Software

  • Eclipse with J2EE supports
  • JDK 1.7
  • Tocat 7
  • Axis2

Steps to write the code

  • Create dynamic web project in eclipse and make sure src/main/java as the src directory of your project to support maven build. Axis2 Select Dynamic web module version as 2.5 during creation of the dynamic web project
  • Create a package called com.ashish.soap
  • Create a simple java class called HelloWorld with the following content

package com.ashish.soap;

public class HelloWorld {
	public String sayHelloWorld(String text) {
		return "Hello World! " + text;
	}
}
  • Download Binary distribution from here and unzip to a location
  • Attach Axis2 with eclipse
     Window -> Preferences -> Web Services -> Axis2 Preference->Select the unzip folder as Axis2 runtime location
    
  • Right click on the project->Properties->Project Facet -> Select Axis2 Web Services as shown below. Now Axis2 framework is integrated with your project.
  • Right click on the project->Configure->Conver to Maven Project
  • Right click on the project->new->web service -> Click on next
  • In service implementation text box fill com.ashish.soap.HelloWorld (fully qualified class name). Then move both the sliders to maximum level(i.e. Test service and Test Client level) and change Webservice runtime to Apache Axis2 as shown below.

  • Click Next and select the style as document/literal as shown below

  • Click next and select as shown below
  • Click on next, next, next… until the end.
  • Another project,SOAPWebServicesClient will get automatically created as the client code.
  • Finally a web browser will get opened in the Eclipse for your testing as shown below

Sanity Testing of your Web Services

Hit the following URL - http://localhost:8080/SOAPWebServices/services/HelloWorld?wsdl from your browser. It will open the generated WSDL file. So your web services deployed properly.

Issues you may face during setup

SL NO Issue Solution
1    


blog comments powered by Disqus
J2EE,SOAP,RESTful,SVN,PMD,SONAR,JaCoCo,HTTP,API,MAVEN,AngularJS,GitHub,LDAP,AOP,ORM,JMS,MVC,AWS,SQL,PHP,H2DB,JDBC