2011-04-07 61 views
0

我嘗試在FUSE(Ver.4.0.0)ESB/OSGi容器中設置camel(版本2.4.0)路由。 它應該是一個簡單的cxf代理,用於將WebService調用從「代理」地址路由到真實服務。FUSE(servicemix)中駝峯cxf路由上的IllegalStateException ESB

我看了幾個文件:

,併成立了春天的配置:

<?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導致啓動包這個例外

[email protected]> 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地址屬性)。

任何幫助帶領我在正確的方向來解決這個問題,將不勝感激。

感謝 克勞斯

回答

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