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

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

问题描述

我已经创建了一个SOAP Web服务,并且希望在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);提供适当的部署,用容器模块依赖项替换嵌入式库,或者禁用当前部署的webservices子系统,并为其添加适当的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提供的链接来设置Web服务.但是,这些示例仅将一个简单功能与一个处理器一起使用.在端口定义中有多个操作时,如何知道调用了哪个函数? 是否有可能让骆驼调用所提供的接口的实现,或者我必须自己映射它?

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

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子系统,您可以将基础WildFly子系统用于您的Camel应用程序.

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天全站免登陆