java2db

How to Create a java web service using bottom up approach



In this approach , we are going to create the service (service implementation) first .Later we will generate the wsdl by using this.   Use @WebService ( javax.jws  annotations) at the top of the class declaration to create a java web service .In the below example , we used Eclipse IDE and Glassfish server .

 

Create a java web service using bottom up approach

Java Web Service Example Steps to create a java web service in Eclipse IDE using bottom up approach :

Java Web Service Example Step 1:

Create new Dynamic Web Project ( bottom-up-web-service) in eclipse IDE and create a new java class (BookInfoWebService.java). See the directory structure below.

 

Create a java web service using bottom up approach

 

 

Java Web Service Example Step 2:

Copy the below java code in  BookInfoWebService.java file.

It is a normal java file having  @webService@WebMethod  annotations  whis is from javax.jws package To do this , we no need to add any external jar files.

 

 

JCreate a java web service using bottom up approach Step 3:

Now , go to File -> New -> Other -> Web Services  and select Web Service .
Create a java web service using bottom up approach

 

 

Create a java web service using bottom up approach Step 4: 

Select Web service type as Bottom up Java bean web Service. Browse and select Service implementation (It will be BookInfoWebService.java) . 

 

 

 

Java Web Service Example Step 5: 

It takes few minutes to create the required files and the wsdl(BookInfoWebService.wsdl) file.

 

BookInfoWebService.wsdl file design :

Create a java web service using bottom up approach

 

 

Java Web Service Example Step 6: 

Now it is the time to test our (Bottom up) web service example.

Testing with SoapUI :  [Example]

Crate a new project (bookInfo) by passing BookInfoWebService.wsdl file location (http://localhost:8080/bottom-up-web-service/BookInfoWebServiceService?wsdl).

Click the availableBooks -> Request 1  and run it . It gives the below output

 

Click the bookPrice -> Request 1  and pass a parameter . It will display the price.

 

Testing with GlassFish Admin Console: Go though this link.

 Also we can test the above web service using Web Browser or Web service Client.



Related Posts :
How to create WCF web service in C# .NET ( visual studio 2013 )
How to call java SOAP web service in php ( php web service client )
What is RESTful web service (Introduction to RESTful web services)
How to call a web service from another web service (web service chain)
How to provide security to SOAP web services ( JAX-WS )
How to handle custom exceptions using SOAP faults in web services
Create a java web service from WSDL (Top down approach) in Eclipse
Top down and Bottom up approach ( java web service )
   [will not be published]



^ <