gpt4 book ai didi

java - 野蝇上的 Camel CXF

转载 作者:行者123 更新时间:2023-12-02 12:00:22 24 4
gpt4 key购买 nike

我创建了一个 SOAP Web 服务,我想在 Wildfly 上使用 Camel-cxf 公开它。

当我想部署它时,出现以下错误:

Apache CXF library (cxf-core-3.2.0.jar) detected in ws endpoint deployment; either provide a proper deployment replacing embedded libraries with container module dependencies or disable the webservices subsystem for the current deployment adding a proper jboss-deployment-structure.xml descriptor to it. The former approach is recommended, as the latter approach causes most of the webservices Java EE and any JBossWS specific functionality to be disabled.

尝试了建议的方法 here但没有用。尝试从我的 pom.xml 中包含的 caml-cxf 中排除 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 提供的链接设置一个网络服务。然而,这些示例仅使用一个处理器的一个简单函数。当我在端口定义中有多个操作时,如何知道调用了哪个函数?是否可以让 Camel 调用所调用的所提供接口(interface)的实现,或者我必须自己映射它?

最佳答案

正如 Claus 指出的,在 WildFly 上使用 Camel 最推荐的方法是使用 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

The camel-cxf endpoint consumer POJO data format is based on the CXF invoker, so the message header has a property with the name of CxfConstants.OPERATION_NAME and the message body is a list of the SEI method parameters.

您可以route a message based on this message header并相应地更改实现。

关于java - 野蝇上的 Camel CXF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47304685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com