0

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

我阅读了几个文档:

并设置以下弹簧配置:

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

我不知道怎么了。我怀疑我的端点地址是错误的,我不知道我的 servlet 地址是什么(没有 cxf:cxfEndoint servelt 地址属性)。

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

谢谢克劳斯

4

1 回答 1

1

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

反而

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

于 2011-04-07T11:01:11.827 回答