Get the online training

Corejava Servlet Jsp  Php  Hibernate  Ajax Web Service   Ejb2.1 Ejb3.0 Struts Struts2  JPA Spring Ibatis   JSF    JSF2.0  CoreJavaDesignPattern    Jquery  Flex J2EE-Design-Patterns  Jboss7  Maven  Contact Me                                                                                                                                                                        
            IGNOU SMU PTU Project                                           Training                                                                                                                              

Contact Us  0091- 9210721663         jaiswaltraining@gmail.com

Web Service

Apache CXF Web Service In Eclipse Indigo

  • Apache Cxf  is web service framework.
  • It has the feature of two java  frame work Celtix and XFire.
  • Clients and End points can be created without  annotation.
  • It has separate  front ends.
  • It is generally used with apache camel and apache activeMQ.

Apache CXF Installation

  • It is not present  in Eclipse as  default.
  • It has to be configured in Eclipse.
  • It can be downloaded from the site cxf.apache.org.
  • Extract it some where let it be c:\.
  • Now start the Eclipse.

  • Click on the Window preference.
  • Come To down.
  • Expand Web Services
  • Click on the CXF2.x Preference.
  • Click on the Add button.

  • It will open a window.
  • Click on the browse Button in CXF Home.
  • Select its value from c:\apache-xcf-2.7.2.
  • Click on the Ok button.
  • This way we have configured Apache CXF in Eclipse.

WebService Project

  • Now we will create  one Dynamic Web Project.
  • Add the name of the project as Welcome.

Java Bean file

  • Create one java bean file in the Welcome project.
  • Add the name of the file as Hello.java.
  • Add the given code.

public class Hello {

  public String disp(String name) {
    return "Welcome " + name;


  • It will open a new window.
  • Select here the required bean.
  • Now we need to change the web service runtime.
  • Click on the Web service runtime.

  • Select Apache CXF 2.x.
  • Click on the Ok button.

  • Now the window is showing the Web service runtime as Apache CXF 2.x
  • This way we have configured the Apache CXF for the given project.

  • Now click on the next button.
  • It is showing you the window to select the SEI(Service End Point).
  • By default it takes the default SEI.
  • If you want to create new SEI, Select Create an SEI.
  • Create on next button.

  • Now here you can select the required annotation in your web service.
  • This will work over disp method.
  • If you are not selecting then it will have code without annotation.
  • Click on the Finish button.
  • This will create web service program based on Hello.java.

  • Now this process has created the folloiwng architecture.
  • It has created two files
    • Disp.java and
    • DispResponse.java
  • Inside WebContent, one directory wsdl has been created.
  • This wsdl directory has hello.wsdl and hello_schema1.xsd.

Testing web service with Web Service Explorer

  • Now our created web service has been deployed on the server.
  • We will test this web service using Web service Explorer.
  • Right click on the hello.wsdl and select Web Services-->Test with Web Services Explorer.

  • It will open the web service explorer in the browser.
  • Now Select the HelloService-->HelloServiceBinding.
  • In the right window select the operation name disp.
  • In the End Point Click on the Add button.

  • Add some value in the end point.
  • Click on the Go button.
  • It will display the result at bottom.

  • In the next section we will see how to create Apache CXF client.

Download the code in the eclipse.