野蝇上的骆驼 cxf [英] camel cxf on wildfly

查看:24
本文介绍了野蝇上的骆驼 cxf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 SOAP 网络服务,我想在 Wildfly 上使用camel-cxf 公开它.

I'v created a SOAP webservice and I'd like to expose it with camel-cxf on wildfly.

当我想部署它时,我收到以下错误:

When I want to deploy it I get the following error:

在 ws 端点部署中检测到 Apache CXF 库 (cxf-core-3.2.0.jar);要么提供适当的部署,用容器模块依赖项替换嵌入式库,要么禁用当前部署的 webservice 子系统,向其添加适当的 jboss-deployment-structure.xml 描述符.推荐使用前一种方法,因为后一种方法会导致大多数 Web 服务 Java EE 和任何 JBossWS 特定功能被禁用.

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.

尝试了此处的建议 但没有用.试图从包含在我的 pom.xml 中的 caml-cxf 中排除 cxf 依赖项:

Tried what was suggested here but didn't work. Tried to exclude the cxf dependencies from the caml-cxf include in my pom.xml:

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

这解决了错误但产生了新的错误:

That solved the error but produces new ones:

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 上部署和扩展的小型工作示例吗?非常感激.

Could you help me resolve these errors or provide a small working example that I can deploy on wildfly and extend? Much appreciated.

在我的 pom.xml 中定义这些依赖项:

Defined these dependencies in my 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:

And here's my 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 提供的链接设置网络服务.然而,这些示例仅使用了一个处理器的一个简单函数.当端口定义中有多个操作时,如何知道调用了哪个函数?是否可以让骆驼调用被调用的提供接口的实现,还是我必须自己映射?

I could set up a webservice with the links provided by @Tadayoshi Sato. The examples, however, only use one simple function with one processor. How do I know which function was called when I have several operations in a port definition? Is it possible to have camel call the implementation of the provided interface that was called or do I have to map that myself?

推荐答案

正如 Claus 所指出的,在 WildFly 上使用 Camel 的最推荐方法是使用 WildFly Camel.您可以在下面的链接中找到如何将 WildFly Camel 子系统安装到 WildFly:
http://wildfly-extras.github.io/wildfly-camel/index.htmlhtml

As Claus pointed out, the most recommended approach to use Camel on WildFly is using WildFly Camel. You can find in the link below how to install the WildFly Camel subsystem to 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

Once you've installed WildFly Camel, let's see this link, where you can find how to develop code using camel-cxf on WildFly:
http://wildfly-extras.github.io/wildfly-camel/index.html#_jax_ws

重点是,WildFly 已经有自己的 CXF 库作为子系统,您需要尽可能多地使用内置库;否则,您可能会遇到问题中的尴尬问题.WildFly Camel 子系统可让您为 Camel 应用程序使用底层的 WildFly 子系统.

The point is that WildFly already has its own CXF libraries as a subsystem and you are required to use the built-in libraries as much as possible; otherwise, you may encounter awkward problems like those in the question. It's the WildFly Camel subsystem that lets you to use the underlying WildFly subsystems for your Camel applications.

更新:

对于camel-cxf 消费者,调用的操作名称可通过CxfConstants.OPERATION_NAME 消息头获得.根据:
https://github.com/apache/camel/blob/master/components/camel-cxf/src/main/docs/cxf-component.adoc

For camel-cxf consumers, the operation name which is called is available via CxfConstants.OPERATION_NAME message header. According to:
https://github.com/apache/camel/blob/master/components/camel-cxf/src/main/docs/cxf-component.adoc

camel-cxf 端点消费者 POJO 数据格式基于 CXF 调用程序,所以消息头有一个名为 CxfConstants.OPERATION_NAME 的属性,消息体是一个 SEI 方法参数列表.

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.

您可以根据此消息标题路由消息并更改相应地实施.

You may route a message based on this message header and change the implementations accordingly.

这篇关于野蝇上的骆驼 cxf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆