骆驼:bean代理到CXF端点 [英] Camel: Bean Proxy to CXF Endpoint

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

问题描述

目前,我正在试图让熟悉的ServiceMix,骆驼,CXF等,并已基本正如有人曾在四年前这里同样的问题:
<一href=\"http://stackoverflow.com/questions/3397591/how-do-i-convert-my-beaninvocation-object-in-camel-to-a-message-body-and-headers\">How将我BeanInvocation对象骆驼到邮件正文和标题?
遗憾的是,答案有不帮我很多。作为其中一个答案提到:在骆驼网站关注自己与CXF送点东西的一个bean所有的例子

I'm currently trying to get familiar with Servicemix, Camel, CXF, etc. and have basically the same question as somebody had four years ago here: How do I convert my BeanInvocation object in camel to a message body and headers? Unfortunately, the answer there don't help me much. As one of the answers mentions: all examples on the Camel website concern themselves with sending something to a bean from CXF.

我有我使用一个POJO一个bean代理的端点,通过

I have a bean proxy endpoint that I'm using in a POJO, injected via

@Produce(uri ="direct:start")
MyService producer; //public interface example.MyService { void myMethod(MyObject o);}

当我用另一端的另一个端点豆,实现该接口的消费者,这一切工作正常。我现在想要做的就是用骆驼CXF消耗实现该接口,而不是Web服务。

When I use another bean endpoint at the other end, implementing a consumer for that interface, this all works fine. What I now would like to do is to use camel-cxf to consume a web service implementing that interface instead. I created a cxfEndpoint via:

<cxf:cxfEndpoint id="cxfEndpoint"
    address="http://localhost:8080/MyService/services/MyService"
    wsdlURL="http://localhost:8080/MyService/services/MyService?wsdl"
    serviceName="s:MyService"
    serviceClass="example.MyService"
    endpointName="s:MyService"
    xmlns:s="http://example" />

什么,我现在基本上试图做的是,在RouteBuilder:

What I'm now basically trying to do is, in a RouteBuilder:

 from( "direct:start" ).to( "cxf:bean:cxfEndpoint" );

但得到一个异常,试图调用代理对象上的东西时:

but get an Exception, when trying invoke something on the proxy object:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Part      
{http://example}o should be of type example.MyObject, not 
org.apache.camel.component.bean.BeanInvocation

据我了解,春节代理对象生成可以由另一个bean端点消耗BeanInvocation对象,我要变成一个方式CXF可以生成一个SOAP请求出它这个(或者是有一些自动转换?)。

From what I understand, the Spring proxy object generates a BeanInvocation object that can be consumed by another bean endpoint, and I have to transform this into a way the cxf can generate a SOAP request out of it (or is there some automatic conversion?).

不过我有点卡住这样做:
我试图肥皂编组作为 http://camel.apache.org/soap.html 或描述写我自己的处理器,但我什至不知道,如果我只是失败,或者如果这不是它应该如何工作的。我也试图把cxfEndpoint设置成无功而返不同的消息模式。

But I'm kind of stuck doing that: I tried soap marshalling as described at http://camel.apache.org/soap.html or writing my own Processor, but I'm not even sure if I just failed, or if that's not how it's supposed to work. I also tried to set the cxfEndpoint into the different message modes without success.

任何指针我应该怎样做一般会大大AP preciated!

Any pointers what I should be generally doing would be greatly appreciated!

推荐答案

所以经过反复试验的一个星期,我发现答案其实很简单。如果cxfEndpoint设置为POJO模式(默认),解决的办法是只获取调用的参数并把它们塞进消息体来代替:

So after a week of trial and error, I found that the answer is quite simple. If the cxfEndpoint is set to POJO mode (the default), the solution is to just grab the invocation parameters and stuff them into the message body instead:

from( "direct:start" ).process( new Processor() {
        @Override
        public void process( Exchange e) throws Exception {
            final BeanInvocation bi = e.getIn().getBody( BeanInvocation.class );
            e.getIn().setBody( bi.getArgs() );
        }
    } ).to( "cxf:bean:cxfEndpoint" )

我想这可能是更优雅但不知何故做。

I guess this could be done more elegantly somehow though.

这篇关于骆驼:bean代理到CXF端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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