CXF combat in Tomcat Publish Web Service (ii)

Source: Internet
Author: User
Tags soap

Service interface and implementation class please refer to WebService Framework CXF combat (i)

Create a MAVEN Web project and add references to the CXF and spring web in Pom.xml, because Cxfservlet requires support from the spring web.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/POM/ 4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">        <modelversion>4.0.0</modelversion>    <groupId>Com.rvho</groupId>    <artifactid>Cxfserver</artifactid>    <version>0.0.1-snapshot</version>    <packaging>War</Packaging>    <properties>        <!--cxf version number --        <cxf.version>3.1.1</cxf.version>    </Properties>    <dependencies>        <!--CXF --        <dependency>            <groupId>Org.apache.cxf</groupId>            <artifactid>Cxf-rt-frontend-jaxws</artifactid>            <version>${cxf.version}</version>        </Dependency>        <dependency>            <groupId>Org.apache.cxf</groupId>            <artifactid>Cxf-rt-transports-http</artifactid>            <version>${cxf.version}</version>        </Dependency>        <!--End CXF --        <!--because Cxfservlet needs the support of spring Web--        <dependency>            <groupId>Org.springframework</groupId>            <artifactid>Spring-web</artifactid>            <version>4.1.7.RELEASE</version>        </Dependency>    </dependencies></Project>

Create the Cxf-servlet.xml configuration file under Web-inf.

<?

xml version="1.0" encoding="UTF-8"?

><beans xmlns =< Span class= "Hljs-value" > "Http://www.springframework.org/schema/beans" xmlns: XSI = "http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws = "Http://cxf.apache.org/jaxws" Span class= "Hljs-attribute" >xmlns:soap = "Http://cxf.apache.org/bindings/soap" xsi:schemalocation = "Http://www.springframe Work.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/ Bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd Http://cxf.apache.org/jaxws Http://cxf.apache. Org/schemas/jaxws.xsd "; <jaxws:server id= "hellowsserver" serviceclass=" Com.rvho.cxfserver.ws.HelloWS " address="/hello "> <jaxws:servicebean> <Bean class="Com.rvho.cxfserver.ws.impl.HelloWSImpl" /> </Jaxws:servicebean> </jaxws:server></Beans>

The Cxfservlet configuration is added to the Web-inf/web.xml, Cxfservlet matches all requests under the/services path.

<?xml version= "1.0" encoding= "UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns= "Http://java.sun.com/xml/ns/javaee" xsi:schemalocation="Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_ 0.xsd "id=" webapp_id " version=" 3.0 ">                <display-name>Cxfserver</display-name>    <!--CXF Servlet ---    <servlet>        <servlet-name>Cxfservlet</servlet-name>        <servlet-class>Org.apache.cxf.transport.servlet.CXFServlet</servlet-class>    </servlet>    <servlet-mapping>        <servlet-name>Cxfservlet</servlet-name>        <!--match all requests under/services--        <url-pattern>/services/*</url-pattern>    </servlet-mapping>    <!--End CXF Servlet ---    <welcome-file-list>        <welcome-file>Index.html</welcome-file>        <welcome-file>index.jsp</welcome-file>    </welcome-file-list></Web-app>


After you start Tomcat. Enter the http://< site path in the browser >/cxfserver/services you can see such as the following effect, because the path to configure Cxfservlet here is/services, assuming that other paths are configured, the service request path is not the same. Just basically the http://< site path >/cxfserver/

CXF combat in Tomcat Publish Web Service (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.