2012-08-04 73 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" />