java – 将CXF SOAP Web服务部署到Apache Tomcat

我最近重写了一个Web服务应用程序来使用CXF而不是Axis.这个开关很简单,但我在部署webapp时遇到了问题.以前,使用Axis,您可以导航到由Tomcat提供服务的页面,该页面将列出所有Axis服务;与http:// localhost:8080 / axis2 / services / listServices类似的东西.要查看服务的WSDL,我将导航到http:// localhost:8080 / axis2 / services / Service?wsdl.

在重写CXF中的服务之后,我发现我真的不知道如何部署和配置应用程序.我遵循了一个基本的CXF设置,我的应用程序的web.xml文件导入了一个Spring配置文件beans.xml.我可以把所有这些都很好地进行战争并将其部署在Tomcat中,它在那里爆炸很好并且没有发生错误记录,但我无法弄清楚如何在主机上浏览以查看已部署的Web服务的列表.

我可以得到一些帮助和解释吗?我想了解如何配置CXF,以便我知道要使用哪些URL来列出服务并查看其相应的WSDL.随意解释这部分就好像我五岁;我是一个可靠的程序员,但部署和配置并不是我最强的知识领域.

我在尝试理解这一点时注意到的一件事是beans.xml文件引用了类路径的导入:META-INF / cxf / cxf.xml.我不知道这个文件是什么或它在哪里,但我的假设是它可能需要它,我应该理解它的作用.有人会介意解释这个吗? Tomcat的web.xml与此配置有什么关系吗?

如果我可以提供更多信息或配置以协助发布此帖子,请告诉我们!

这是我的应用程序的web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<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"
    version="3.0">
    <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>
        <display-name>CXF Servlet</display-name>
        <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>
    <mime-mapping>
        <extension>inc</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>
</web-app>

这是我的beans.xml:

<?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.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml" />

    <jaxws:endpoint
        id="accountService"
        implementor="com.company.ws.data.services.AccountService"
        address="/AccountService" />

    <jaxws:endpoint
        id="loggingService"
        implementor="com.company.ws.data.services.LoggingService"
        address="/LoggingService" />

    <jaxws:endpoint
        id="searchService"
        implementor="com.company.ws.data.services.SearchService"
        address="/SearchService" />

    <jaxws:endpoint
        id="validationService"
        implementor="com.company.ws.data.services.ValidationService"
        address="/ValidationService" />
</beans>

解决方法:

您可以访问http:// localhost:8080 / {YourwebApp} / services中的所有已部署的Web服务.假设您的webapplication是webapp1,那么http:// localhost:8080 / webapp1 / services

上一篇:Apache CXF :: wsdl2java忽略公共条目的目录配置


下一篇:如何从CXF端点调用Spring Integration应用程序