Camel Http代理Web服务

时间:2014-12-09 11:14:38

标签: java http soap cxf apache-camel

我已经阅读了一些关于Camel的内容,并浏览了下载目录中的一些示例。

我想知道我是否可以使用jetty:或servlet配置路由以接受带有参数name = fred的传入Http请求:

然后我需要将其转换为真正的安全SOAP请求(HTTPS)并获取SOAP响应。

我是否必须编写Java代码来发送SOAP请求?我到目前为止看到的例子是使用SOAP作为输入,修改一些值并将其作为SOAP发送...

任何人都可以用最少的代码提供一些指导吗?

谢谢&问候 锡

1 个答案:

答案 0 :(得分:1)

这是我所做的,它的工作原理..     velocity_template.vm包含整个SOAP请求,其中动态字段在运行时被替换,例如。 $ {in.headers.name}

<?xml version="1.0" encoding="UTF-8"?>

<!-- START SNIPPET: e1 -->
<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:cxf="http://camel.apache.org/schema/cxf"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.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">

    <cxf:cxfEndpoint id="real_webservice"
                     address="url_to_wsdl?wsdl"
                     endpointName="s:Real_impl_class"
                     xmlns:s="real_namespace"/>

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

        <route id="helloRoute">
          <from uri="servlet:///hello"/>
          <to uri="velocity:etc/velocity_template.vm"/>
          <to uri="cxf:bean:real_webservice?dataFormat=MESSAGE"/>
        </route>

  </camelContext>

</beans>
  <!-- END SNIPPET: e1 -->