FUSE (servicemix) ESB 中的camel cxf 路由存在 IllegalStateException

发布于 2024-10-30 23:02:57 字数 3420 浏览 10 评论 0原文

我尝试在 FUSE(版本 4.3.0)ESB/OSGi 容器中设置骆驼(版本 2.4.0)路由。 它应该是一个简单的 cxf-proxy,用于将 WebService 调用从“代理”地址路由到真实服务。

我阅读了几个文档:

并设置以下 spring 配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:camel="http://camel.apache.org/schema/spring"
    xmlns:osgi="http://www.springframework.org/schema/osgi"
    xmlns:cxf="http://camel.apache.org/schema/cxf"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/osgi
        http://www.springframework.org/schema/osgi/spring-osgi.xsd
        http://camel.apache.org/schema/osgi
        http://camel.apache.org/schema/osgi/camel-osgi.xsd
        http://camel.apache.org/schema/spring
        http://camel.apache.org/schema/spring/camel-spring.xsd
        http://camel.apache.org/schema/cxf
        http://camel.apache.org/schema/cxf/camel-cxf.xsd">

    <import
        resource="classpath:META-INF/cxf/cxf.xml" />
    <import
        resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import
        resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
    <import
        resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />

    <!-- the proxy service -->
    <cxf:cxfEndpoint
        id="myServiceProxy"
        address="http://localhost:9003/cxf/myService"
        serviceClass="foo.bar.iface.MyServiceInterface" />

    <!-- my real existing cxf soap service -->
    <cxf:cxfEndpoint
        id="myService"
        address="http://foo.bar/services/myService"
        wsdlURL="http://foo.bar/services/myService?wsdl"
        serviceClass="foo.bar.iface.MyServiceInterface"
        serviceName="s:MyService"
        endpointName="s:MyServiceEndpoint"
        xmlns:s="http://foo.bar/iface/" />

    <!-- route -->
    <camel:camelContext>
        <camel:route>
            <camel:from
                uri="cxf:bean:myServiceProxy" />
            <camel:to
                uri="cxf:bean:myService" />
        </camel:route>
    </camel:camelContext>

</beans>

尝试在 FUSE 中启动捆绑包会导致此异常

karaf@root> Exception in thread "SpringOsgiExtenderThread-22" org.apache.camel.RuntimeCamelException: java.lang.IllegalStateException: Endpoint address should be a relative URI wrt to the servlet address (use '/xxx' for example)
        at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1126)
        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
        at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:231)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)

我不知道出了什么问题。我怀疑我的 Endpoint 地址是错误的,并且我不知道我的 servlet 地址是什么(没有 cxf:cxfEndointservelt 地址属性)。

任何帮助引导我朝着正确的方向解决这个问题的帮助将不胜感激。

谢谢 克劳斯

I try to set up a camel (Ver. 2.4.0) route in a FUSE (Ver. 4.3.0) ESB/OSGi container.
It should be a simple cxf-proxy to route a WebService call from a 'proxy' address to a real service.

I read several documentation:

and set up the following spring configuration:

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:camel="http://camel.apache.org/schema/spring"
    xmlns:osgi="http://www.springframework.org/schema/osgi"
    xmlns:cxf="http://camel.apache.org/schema/cxf"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/osgi
        http://www.springframework.org/schema/osgi/spring-osgi.xsd
        http://camel.apache.org/schema/osgi
        http://camel.apache.org/schema/osgi/camel-osgi.xsd
        http://camel.apache.org/schema/spring
        http://camel.apache.org/schema/spring/camel-spring.xsd
        http://camel.apache.org/schema/cxf
        http://camel.apache.org/schema/cxf/camel-cxf.xsd">

    <import
        resource="classpath:META-INF/cxf/cxf.xml" />
    <import
        resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import
        resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
    <import
        resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />

    <!-- the proxy service -->
    <cxf:cxfEndpoint
        id="myServiceProxy"
        address="http://localhost:9003/cxf/myService"
        serviceClass="foo.bar.iface.MyServiceInterface" />

    <!-- my real existing cxf soap service -->
    <cxf:cxfEndpoint
        id="myService"
        address="http://foo.bar/services/myService"
        wsdlURL="http://foo.bar/services/myService?wsdl"
        serviceClass="foo.bar.iface.MyServiceInterface"
        serviceName="s:MyService"
        endpointName="s:MyServiceEndpoint"
        xmlns:s="http://foo.bar/iface/" />

    <!-- route -->
    <camel:camelContext>
        <camel:route>
            <camel:from
                uri="cxf:bean:myServiceProxy" />
            <camel:to
                uri="cxf:bean:myService" />
        </camel:route>
    </camel:camelContext>

</beans>

Trying to start the bundle in FUSE leads to this exception

karaf@root> Exception in thread "SpringOsgiExtenderThread-22" org.apache.camel.RuntimeCamelException: java.lang.IllegalStateException: Endpoint address should be a relative URI wrt to the servlet address (use '/xxx' for example)
        at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1126)
        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
        at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:231)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)

I do not know what's wrong. I doubt that my Endpoint address is wrong and I do not know what my servlet address is (there is no cxf:cxfEndoint servelt address attribute).

Any help to lead me in the right direction to solve this problem would be appreciated.

Thanks
Klaus

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久夏青 2024-11-06 23:02:57

我终于发现出了什么问题。

相反,

<!-- the proxy service -->
<cxf:cxfEndpoint
    id="myServiceProxy"
    address="http://localhost:9003/cxf/myService"
    serviceClass="foo.bar.iface.MyServiceInterface" />

它必须是

<!-- the proxy service -->
<cxf:cxfEndpoint
    id="myServiceProxy"
    address="/myService"
    serviceClass="foo.bar.iface.MyServiceInterface" />

由于第一种方法在 FUSE 外部运行骆驼项目效果很好(在这种情况下,将启动 http 服务器来提供服务),因此它必须是 FUSE 内部的相对地址。

在 FUSE 内部,将使用在 (localhost:8181) 上运行的嵌入式 HTTP 服务器,并且服务 URL 将扩展为 http://localhost:8181/cxf/myService

I finally found out what's wrong.

Instead

<!-- the proxy service -->
<cxf:cxfEndpoint
    id="myServiceProxy"
    address="http://localhost:9003/cxf/myService"
    serviceClass="foo.bar.iface.MyServiceInterface" />

it has to be

<!-- the proxy service -->
<cxf:cxfEndpoint
    id="myServiceProxy"
    address="/myService"
    serviceClass="foo.bar.iface.MyServiceInterface" />

As the first approach worked well running the camel project outside FUSE (in this case a the http server will be started to provide the service) it has to be a relative address inside FUSE.

Inside FUSE the embedded HTTP server which runs on (localhost:8181) will be used and the service url will be extended to http://localhost:8181/cxf/myService.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文