This article describes how to install the cxf plug-in eclipse [3.3.2. Develop a simple Java Web Service and integrate it with spring.
Install plug-ins:
1. Download STP all_in_one from
Install this plug-in, you can use the link file to install, refer to http://blog.csdn.net/kkdelta/archive/2009/03/12/3983999.aspx
2. Download the jar package required by the cxf runtime environment,
 
Http://people.apache.org/repo/m2-snapshot-repository/org/apache/cxf/apache-cxf/
 
I use a apache-cxf-2.1-incubator-20080414.232258-49.zip.
3. Open eclipse. On the menu bar, choose windows> preference> SOA tools. For example, the plug-in is successfully installed.
 
4. Configure the cxf running environment, for example, installed runtimes ---- add -- appach cxf 2.0 -- next indicates the path of apache-cxf-2.1-incubator-20080414.232258-49.zip to be decompressed.
 
 
 
Develop Web Java Service
1. Create a web project and create the following interface in the project:
Package com. Test. cxf;
Public interface wsprovider {
Public String testws (string msgin );
}
Right-click the created Project, JAX-WS tools --- enable JAX-WS -- Java first programing mode, and choose run cxf environment -- select new interface -- finish.
Java anotation will be added to your interface as follows:
 
package com.test.cxf;import javax.jws.WebService;@WebService(name="WSprovider", targetNamespace="http://cxf.test.com/")public interface WSprovider {    public String testWS(String msgIn);} 
 
2. In the outline view, right-click testws () and choose JAX-WX tools --> Create web method
Java anotation will be added to your interface as follows:
 
@WebService(name="WSprovider", targetNamespace="http://cxf.test.com/")public interface WSprovider {    @WebMethod(operationName="testWS", exclude=false)    @ResponseWrapper(className="com.test.cxf.TestWSResponse", localName="testWSResponse", targetNamespace="http://cxf.test.com/")    @RequestWrapper(className="com.test.cxf.TestWS", localName="testWS", targetNamespace="http://cxf.test.com/")    public String testWS(String msgIn);} 
3, then right click on the project, JAX-WS tools --- generate all
The interface implementation class is generated as follows:
 
 
@WebService(endpointInterface = "com.test.cxf.WSprovider", serviceName = "WSproviderService")                     public class WSproviderImpl implements WSprovider {    public java.lang.String testWS(java.lang.String arg0) {         ........    }} 
By now, the development of simple web services is complete.
Integrate spring
1. Create a bean. xml file under the WEB-INF:
 
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns:jaxws="http://cxf.apache.org/jaxws"    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">    <import resource="classpath:META-INF/cxf/cxf.xml" />    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />    <bean name="testService" class="com.test.cxf.WSCXFProviderImpl"/>       <jaxws:endpoint        id="testEndpoint"        implementor="#testService"        wsdlLocation="classpath:wsdl/prjCXFWeb.wsdl"        address="/WSCXFProviderPort">        <jaxws:features>            <bean class="org.apache.cxf.feature.LoggingFeature"/>        </jaxws:features>    </jaxws:endpoint>     </beans>
 
2. Modify the generated WSDL file:
<Soap: address location = "http: // localhost: 9090/wsproviderport"/>
Change to <soap: address location = "http: // localhost: 8080/prjcxfweb/services/wscxfproviderport"/>
Create a new WSDL file in your src file and copy the modified WSDL to this file [to correspond to wsdllocation in bean. xml ].
 
3. Add the following content to Web. xml:
 
  <context-param>        <param-name>contextConfigLocation</param-name>        <param-value>WEB-INF/beans.xml</param-value>    </context-param>    <listener>        <listener-class>            org.springframework.web.context.ContextLoaderListener        </listener-class>    </listener>    <servlet>        <servlet-name>CXFServlet</servlet-name>        <servlet-class>            org.apache.cxf.transport.servlet.CXFServlet        </servlet-class>        <load-on-startup>1</load-on-startup>    </servlet>    <servlet-mapping>        <servlet-name>CXFServlet</servlet-name>        <url-pattern>/services/*</url-pattern>    </servlet-mapping>
 
4. Publish the WEB Project to Web iner (e. g Tomcat), and the Web service can be called.
In IE, enter http: // localhost: 8080/prjcxfweb/services/wscxfproviderport? WSDL. You can see the WSDL file to prove it.
The Web service has been published successfully.
 
If it is not integrated with spring, you can implement a cxfnonspringservlet Servlet and configure this servlet in Web. XML to process Web Service requests.
 
public class SimpleServlet extends CXFNonSpringServlet {    private static final long serialVersionUID = 1L;    public void loadBus(ServletConfig servletConfig) throws ServletException {        super.loadBus(servletConfig);        BusFactory.setDefaultBus(getBus());        Object implementor = new WSCXFProviderImpl();        Endpoint.publish("/p1", implementor);    }}    <!-- not using Spring -->    <servlet>        <servlet-name>CXFServlet</servlet-name>        <servlet-class>            com.bt.cxf.ws.SimpleServlet        </servlet-class>        <load-on-startup>1</load-on-startup>    </servlet>    <servlet-mapping>        <servlet-name>CXFServlet</servlet-name>        <url-pattern>/services/*</url-pattern>    </servlet-mapping> 
In IE, enter http: // localhost: 8080/prjcxfweb/services/P1? WSDL. You can see the WSDL file to prove it.
 
The Web service has been published successfully. [P1 corresponds to ndpoint. Publish ("/P1", implementor);]