Pages

Showing posts with label Bottom-UP. Show all posts
Showing posts with label Bottom-UP. Show all posts

Sunday, 14 October 2012

Creating Code First Web Service (Bottom-UP Approach)

Creating Code First(Bottom-UP approach) Web Service:
I have been talking about bottom up approach for creating web services in this post with using eclipse.
Bottom up we need to write first java code like beans or enterprise beans where as In contract first ,
We need to define contract like XSD,Schema  and wsdl.

Setup Eclipse for developing web services in java:
We need to different software setup like JDK,Web Server or App Server,WTP,etc.  

Prerequisite Installation:
Install JDK
Install Web Server or App Server like Tomcat, boss.
Install Eclipse like Indigo, Helios, etc.

Setup:
1-When Eclipse is installed then you can check your eclipse preferences (Windows -> Preferences) where Web Service preference is present in the list or not.

 If Web Service preference is not there then you need to plugin WTP (Web Tools Platform) after plugin Web Services link would be available in the eclipse. Link for Helios plugin http://download.eclipse.org/webtools/repository/helios/




2-Configure installed JRE in eclipse (Windows -> Preferences -> Java -> Installed JREs)


3-Setup CXF or Axis2 runtime: In eclipse go to Windows -> Preferences
 And select CXF or Apache Axis2 as per runtime adds runtime to eclipse for creating web services.

I have taken Apache CXF for creating service so I select the CXF preference.






Click on Add button and browse the Apache CXF runtime.



Click Finish button and get the added CXF runtime.then apply and ok




Creating a Web service: Now, we can start to create web service on eclipse using Apache CXF runtime.

Steps:
1-Create a dynamics web project in Eclipse.


  a-      project name ex. StandardWebService
 b-     Select Runtime like apache tomcat v7.0
 c-      Click on modify button for setting facts.

2-Select Apache CXF runtime
Click on modify button, you can select the CXF check box for this project.


Here we can select Apache cxf or apache axis as engine for creating service. Now i am using apache cxf engine for creating service.

3-Write the Java classes which you want create as service:


I have written these classes as sample like

a-      Product

b-      ProductService (it is interface, it has two methods)

c-      ProductServiceImpl (it is implementation of product service)