2012-08-04 80 views
2

我想用camel做一個簡單的代碼,將URL監聽器重定向到soap web服務。 我有一個簡單的PHP helloWorld SOAP Web服務可用。我想鍵入http://localhost:8080/test並將其路由到外部SOAP Web服務。 最終目標是將soap轉換爲REST/JSON。Camel:jetty作爲輸入,soap作爲輸出

這裏是我的駱駝context.xml中:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/cxf" 
    xmlns:camel="http://camel.apache.org/schema/spring" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" 
    xsi:schemaLocation=" 
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.0.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 
      http://cxf.apache.org/transports/http/configuration 
      http://cxf.apache.org/schemas/configuration/http-conf.xsd"> 

    <import resource="classpath:META-INF/cxf/cxf.xml" /> 

<cxf:cxfEndpoint id="helloEp"      
        address="http://test.mydomain.com/soap/hello.php" 
        serviceClass="com.seb.helloEndPoint" 
        wsdlURL="http://test.mydomain.com/soap/hello.php?wsdl"/> 

    <camelContext xmlns="http://camel.apache.org/schema/spring"> 
    <package>com.seb</package> 
    <route> 
     <from uri="jetty://http://0.0.0.0:8080/test"/>    
     <to uri="cxf:bean:helloEp"/> 
    </route> 
    </camelContext> 
</beans> 

和結果的輸入駱駝當部分:運行:

[pache.camel.spring.Main.main()] MainSupport     INFO Apache Camel 2.9.0 starting 
[pache.camel.spring.Main.main()] CamelNamespaceHandler   INFO OSGi environment not detected. 
[pache.camel.spring.Main.main()] SpringCamelContext    INFO Apache Camel 2.9.0 (CamelContext: camel-1) is starting 
[pache.camel.spring.Main.main()] ManagementStrategyFactory  INFO JMX enabled. Using ManagedManagementStrategy. 
[pache.camel.spring.Main.main()] ultManagementLifecycleStrategy INFO StatisticsLevel at All so enabling load performance statistics 
[pache.camel.spring.Main.main()] AnnotationTypeConverterLoader INFO Found 3 packages with 15 @Converter classes to load 
[pache.camel.spring.Main.main()] DefaultTypeConverter   INFO Loaded 168 core type converters (total 168 type converters) 
[pache.camel.spring.Main.main()] AnnotationTypeConverterLoader INFO Loaded 5 @Converter classes 
[pache.camel.spring.Main.main()] DefaultTypeConverter   INFO Loaded additional 23 type converters (total 191 type converters) in 0.023 seconds 
[pache.camel.spring.Main.main()] ReflectionServiceFactoryBean INFO Creating Service {http://seb.com/}helloEndPointService from WSDL: http://test.mydomain.com/soap/hello.php?wsdl 

但是,當我在Web瀏覽器中鍵入http://127.0.0.1:8080/test我有一個「無法加載頁面」的空白頁面。我還嘗試使用http://127.0.0.1:8080/test和同一個問題(未能加載外部實體「http://127.0.0.1:8080/test」)上的PHP SOAP客戶端腳本。

任何人都可以解釋我做錯了什麼?

謝謝!

+0

你可以嘗試像一個簡單的telnet測試的詳細信息:遠程登錄本地主機8080,看看你是否有在該端口上監聽器?另外0.0.0.0應該監聽所有接口。有時我發現我必須使用實際的機器IP地址而不是回送地址。你可以試試這些嗎? – 2013-01-17 00:04:20

回答

0

幾件事情。打開跟蹤並查看日誌。我很確定你的問題在cxf方面。

<camelContext trace="true" xmlns="http://activemq.apache.org/camel/schema/spring"> 

您還需要在您的端點,以指定這樣的例子

 <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9000/SoapContext/SoapPort" 
     wsdlURL="testutils/hello_world.wsdl" 
     serviceClass="org.apache.hello_world_soap_http.Greeter" 
     endpointName="s:SoapPort" 
     serviceName="s:SOAPService" 
    xmlns:s="http://apache.org/hello_world_soap_http" />