2012-12-05 70 views
8

我是新來的任何開放框架(我是一個基於java的解決方案工程師),並試圖建立一個cxf項目。在哪裏可以找到cxf/cxf.xml,cxf-extension-soap.xml,cxf-servlet.xml

我明白,我需要有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項目是錯誤的?其他一些項目類型是否自動生成這些文件?

+0

或任何指南的基本cfx環境設置找到更多的細節?球員? –

回答

3

這些文件中的每一個都可以在您需要包含在項目中的CXF jar中找到。

cxf-servlet.xml

cxf.xml

cxf-extension-soap.xml

我一直認爲以最快的方式得到一個CXF項目運行起來使用Maven原型。

+3

有許多CXF罐子。用戶希望知道哪一個。 –

7

我知道這是舊的文章,但是這可能幫助別人

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

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

cxf.xmlcxf-rt-core罐子(這是上述的傳遞依賴)

因此,如果包含cxf-rt-frontend-jaxwscxf-rt-transports-http作爲依賴項(例如Maven),您的項目應該正常工作。

2

或者我創建的動態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 

,當你建立你的項目,以創建一個罐子或戰爭這個目錄會自動創建。它可以具有其他屬性,如主類 [Refer this Q]

現在來你的問題。許多庫將它們的配置文件放入相應的jar META-INF文件夾中。這只是另一個例子,你正在尋找的罐子是CXF罐子。

enter image description here enter image description here

對於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") 
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> 

所有行家依賴性被定義如下,其中包括CXF/cxf.xml,CXF延伸-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