我尝试在FUSE(Ver.4.3.0)ESB / OSGi容器中设置camel(Ver.2.4.0)路由。 它应该是一个简单的cxf代理,用于将WebService调用从“代理”地址路由到实际服务。
我读了几篇文档:
并设置以下弹簧配置:
<?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地址属性)。
任何有助于我正确指导解决这个问题的帮助都将不胜感激。
由于 克劳斯
答案 0 :(得分: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
。