[英]camel cxf on wildfly
我创建了一个SOAP Web服务,并想在wildfly上用camel-cxf公开它。
当我要部署它时,出现以下错误:
在ws端点部署中检测到Apache CXF库(cxf-core-3.2.0.jar); 提供适当的部署,用容器模块依赖项替换嵌入式库,或者为当前部署禁用webservices子系统,并向其添加适当的jboss-deployment-structure.xml描述符。 建议使用前一种方法,因为后一种方法会导致大多数Web服务Java EE和任何JBossWS特定功能被禁用。
尝试了这里提出的建议,但是没有用。 试图从我的pom.xml中的caml-cxf include中排除cxf依赖项:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.20.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
那解决了错误,但产生了新的错误:
Failed to define class org.apache.camel.component.cxf.spring.AbstractCxfBeanDefinitionParser in Module "deployment.CamelCXF-1.0.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/apache/camel/component/cxf/spring/AbstractCxfBeanDefinitionParser
Failed to define class org.apache.camel.component.cxf.spring.CxfEndpointBeanDefinitionParser in Module "deployment.CamelCXF-1.0.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser
Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/camel.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.apache.camel.component.cxf.spring.NamespaceHandler] for namespace [http://camel.apache.org/schema/cxf]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: Failed to link org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser
您能否帮助我解决这些错误,或者提供一个可以在wildfly上进行部署和扩展的小型示例? 非常感激。
在我的pom.xml中定义了这些依赖项:
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.20.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
这是我的camel.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<cxf:cxfEndpoint id="customerEndpoint"
address="http://localhost:8080/TestService/"
serviceClass="my.package.TestService"
wsdlURL="WEB-INF/CustomerService.wsdl"/>
<bean id="logBean" class="my.package.LogBean"/>
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="cxf:bean:customerEndpoint" />
<to uri="bean:logBean" />
</route>
</camel:camelContext>
我可以使用@Tadayoshi Sato提供的链接来设置Web服务。 但是,这些示例仅将一个简单功能与一个处理器一起使用。 在端口定义中有多个操作时,如何知道调用了哪个函数? 是否可以让骆驼调用所提供的接口的实现,或者我必须自己映射它?
正如克劳斯指出的,在WildFly上使用骆驼的最推荐方法是使用WildFly Camel。 您可以在下面的链接中找到如何将WildFly Camel子系统安装到WildFly:
http://wildfly-extras.github.io/wildfly-camel/index.html
安装WildFly Camel之后,让我们看一下此链接,您可以在其中找到如何在WildFly上使用camel-cxf开发代码:
http://wildfly-extras.github.io/wildfly-camel/index.html#_jax_ws
关键是WildFly已经拥有自己的CXF库作为子系统,并且您需要尽可能多地使用内置库。 否则,您可能会遇到类似问题的尴尬问题。 它是WildFly Camel子系统,可让您将基础WildFly子系统用于您的Camel应用程序。
更新:
对于camel-cxf使用者,可以通过CxfConstants.OPERATION_NAME
消息头获得被调用的操作名称。 根据:
https://github.com/apache/camel/blob/master/components/camel-cxf/src/main/docs/cxf-component.adoc
camel-cxf端点使用者POJO数据格式基于CXF调用程序 ,因此消息头具有名称为
CxfConstants.OPERATION_NAME
的属性,消息主体是SEI方法参数的列表。
您可以基于此消息头路由消息,并相应地更改实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.