SOAP : Building a WebService

We will be using annotation for creating webservices and deploying on jboss server. Since JBoss comes with JAX-WS jars inbuilt, we will not be adding any jars. First lets setup the jboss env.

Download Jboss from here. I downloaded jboss-eap-6.2. Extract the zip file. Add the server to Eclipse and start. Now, in order to access the adminn console you first have to create a user. Follow these steps:

  • Invoke the or  add-user.bat script from commond promt or terminal. Options to setup a user will come.
  • Choose to add a management user. Enter username password and other required details.

You can check more details about setup here.

Lets create the webserice.

Create a dynamic web project. Create a class EmployeeDetails. For now I have hardcoded the return values.


import java.util.ArrayList;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;

public class EmployeeDetails {

 public List<String> getAllEmployees(){
 List<String> mylist=new ArrayList<String>();
 //some DB connection
 return mylist;


 public int getTotalEmpCount(){
 return Integer.MAX_VALUE;


And Thats it!!!.. Its done. Deploy it on jboss server and open the admin console:


Notice the WSDL url which you can share wiwth your webservice consumer who can then generate client accordingly.

To test any webservice we can follow the generate client approach as discussed in the previous post, but there is an quick alternate way. Open Run -> Launch Web Service Explorer




SoapUI is an open source web service testing application for service-oriented architectures (SOA). Its functionality covers web serviceinspection, invoking, development, simulation and mocking, functional testing, load and compliance testing.

Download SoapUI from here, and install.

In the SoapUI interface create a new soap project and give the WSDl url in the Intial WSDL box:


This will create all sample request. Since we do not have any input parameter so we can directly run the request. The respose will be displayed on the righ side.


Lets go back to the class we created the @WebMethod is actually optional, because once you annotate the class with @WebService every public method of the class is considered to be an operation.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: