我是任何开放框架的新手(我是基于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项目是错误的?是否有其他项目类型会自动生成这些文件?
我知道这是一个老帖子,但这可能对其他人有帮助
cxf-extension-soap.xml
在cxf-rt-binding-soap
jar,但你需要cxf-rt-frontend-jaxws
cxf-servlet.xml
在cxf-rt-transports-http
jar
cxf.xml
在cxf-rt-core
jar(这是上述的传递依赖)
因此,如果您将cxf-rt-frontend-jaxws
和cxf-rt-transports-http
包含为依赖项(例如,使用Maven),您的项目应该可以正常工作。
这些文件中的每一个都可以在您需要包含在项目中的CXF jar中找到。
我总是发现启动和运行CXF项目的最快方法是使用Maven Archetype。
或者我创建动态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时,将自动创建此目录。它可以有其他属性,就像主class [Refer this Q]一样。
现在回答你的问题。许多库将其配置文件放在相应的jar 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")
这是一个老帖子,但它仍然适用于将旧的CXF迁移到更新的人。我发现的是cxf-rt-bindings-soap-3.1.7.jar
不再有classpath:META-INF/cxf/cxf-extension-soap.xml
看到这个:REST CXF and Spring cxf-extension-jaxrs-binding File not found exception?
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的jar,cxf-extension-soap.xml,cxf-servlet.xml
<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找到更多详情
cxf版本3.2.X的cxf-extension-http.xml和cxf-extension-soap.xml你只需要包含这行cxf-extension-jaxws.xml