12

我是任何开放框架的新手(我是基于 java 的解决方案工程师)并试图构建一个 cxf 项目。

我知道我需要有applicationContext.xml类似的文件和内容

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
        http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.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" />

<http-conf:conduit name="*.http-conduit">
    <http-conf:client ReceiveTimeout=“300000“ AllowChunking="false"/>
</http-conf:conduit>

<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" />

<cxf:bus>
    <cxf:features>
        <cxf:logging />
    </cxf:features>
</cxf:bus>

</beans>

在里面。

我现在想知道在哪里可以下载
cxf/cxf.xml, cxf-extension-soap.xml, cxf-servlet.xml文件。

还是说我创建了一个动态 Web 项目是错误的?其他一些项目类型会自动生成这些文件吗?

4

6 回答 6

10

我知道这是一个旧帖子,但这可能对其他人有所帮助

cxf-extension-soap.xmlcxf-rt-binding-soap罐子里,但你需要cxf-rt-frontend-jaxws

cxf-servlet.xmlcxf-rt-transports-http罐子里

cxf.xmlcxf-rt-corejar 中(这是上述依赖项的传递依赖项)

因此,如果您包含cxf-rt-frontend-jaxwscxf-rt-transports-http作为依赖项(例如,使用 Maven),您的项目应该可以正常工作。

于 2015-07-22T10:01:01.217 回答
4

还是说我创建了一个动态 Web 项目是错误的?其他一些项目类型会自动生成这些文件吗?

您创建的 war 文件通常只有一个清单文件位于META-INF名为MANIFEST.MF. 此文件包含您的构建元信息。对我来说我有

Manifest-Version: 1.0
Gradle-Version: 2.0-rc-2
Created-By: 1.6.0_31 (Sun Microsystems Inc.)
Version: 10.51
Build: dev
Build-Timestamp: 10/01/2015 12:53:32
Build-User: athakur
Build-Host: ATHAKUR

当您构建项目以创建 jar 或 war 时,会自动创建此目录。它可以具有其他属性,例如主类[Refer this Q]

现在来回答你的问题。许多库将其配置文件放在相应的 jars META-INF 文件夹中。这只是另一个示例,您要查找的罐子是 CXF 罐子。

在此处输入图像描述 在此处输入图像描述

对于 gradle,您可以在build.gradle文件中添加以下内容

compile("org.apache.cxf:cxf-rt-frontend-jaxrs:3.1.3")
compile("org.apache.cxf:cxf-rt-frontend-jaxws:3.1.3")
compile("org.apache.cxf:cxf-rt-transports-http:3.1.3")
于 2015-10-06T05:48:29.780 回答
3

这些文件中的每一个都可以在您需要包含在项目中的 CXF jar 中找到。

cxf-servlet.xml

cxf.xml

cxf-扩展-soap.xml

我一直发现启动和运行 CXF 项目的最快方法是使用 Maven Archetype。

于 2012-12-09T22:59:15.607 回答
2

这是一篇旧帖子,但它仍然适用于将旧 CXF 迁移到新版本的人。我发现cxf-rt-bindings-soap-3.1.7.jar不再有classpath:META-INF/cxf/cxf-extension-soap.xml

看到这个:REST CXF 和 Spring cxf-extension-jaxrs-binding File not found 异常?

于 2016-10-17T19:02:47.567 回答
0

cxf 3.2.X 版本的 cxf-extension-http.xml 和 cxf-extension-soap.xml 你只需要包含这一行 cxf-extension-jaxws.xml

于 2018-09-10T12:30:00.600 回答
0

web.xml可以是这样的

CXF

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:ApplicationContext-cxf.xml</param-value>
</context-param>

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

<servlet>
    <servlet-name>CXFServlet</servlet-name>
    <display-name>CXF Servlet</display-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>/*</url-pattern>
</servlet-mapping>

以下是一个工作 ApplicationContext.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" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:cxf="http://cxf.apache.org/core" xmlns:task="http://www.springframework.org/schema/task"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
     http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd">


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

    <task:annotation-driven />

    <context:component-scan base-package="com.smoothexample">
        <context:include-filter type="annotation"
            expression="org.springframework.stereotype.Service" />
        <context:include-filter type="annotation"
            expression="org.springframework.stereotype.Component" />
        <context:include-filter type="annotation"
            expression="org.springframework.stereotype.Repository" />
    </context:component-scan>

    <context:annotation-config />
    <context:component-scan base-package="com.smoothexample" />


    <bean
        class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />


<bean id="addressSoapService" class="com.smoothexample.cxf.soap.ws.impl.AddressSoapServiceImpl" />

    <jaxws:endpoint id="addressEndpointId"
        implementorClass="com.smoothexample.cxf.soap.ws.impl.AddressSoapServiceImpl"
        implementor="#addressSoapService" address="/addressSoapService">

    </jaxws:endpoint>

</beans>

所有的maven依赖定义如下,包括cxf/cxf.xml、cxf-extension-soap.xml、cxf-servlet.xml的jar

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.lal.pro</groupId>
    <artifactId>apache-cxf-soap-ws</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>apache-cxf-soap-ws Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <cxf.version>2.5.0</cxf.version>

        <org.springframework.version>4.1.1.RELEASE</org.springframework.version>

        <ch.qos.logback.version>1.1.3</ch.qos.logback.version>
        <org.sl4j.version>1.7.12</org.sl4j.version>
        <spring.ws.version>2.2.4.RELEASE</spring.ws.version>
    </properties>
    <dependencies>

        <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>


        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.1</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>apache-cxf-soap-ws</finalName>
    </build>
</project>

请在http://www.smoothexample.com/webservices/apache_cxf_soap_web_services.html找到更多详细信息

于 2016-11-26T20:12:35.950 回答