java - 如何在 Spring-Integration 中将 SOAPAction header 添加到 HTTP 消息中?

标签 java spring spring-integration

我有以下 HTTP 出站网关。

<int-http:outbound-gateway id="myWs"
    request-channel="requests"
    url="http://localhost/test"
    http-method="POST"
    charset="UTF-8"
    reply-timeout="1234"/>

我想将 SAOPAction 添加到 HTTP header 。我怎样才能做到这一点? 使用出站 Web 服务网关对我来说不是一个选项,因为我的 SOAP 信封不是标准的 SOAP 信封。

最佳答案

使用 header 丰富器和自定义 header 映射器 ...

<int:chain input-channel="requestChannel">
    <int:header-enricher>
        <int:header name="SOAPAction" value="http:/foo/bar" />
    </int:header-enricher>
    <int-http:outbound-gateway
                            header-mapper="mapper"
                            url="http://localhost:18080/http/receiveGateway"
                            http-method="POST"
                            expected-response-type="java.lang.String"/>
</int:chain>

<bean id="mapper" class="org.springframework.integration.http.support.DefaultHttpHeaderMapper">
    <property name="userDefinedHeaderPrefix" value=""/> <!-- remove the default X- prefix -->
    <property name="outboundHeaderNames" value="SOAPAction" />
</bean>

关于java - 如何在 Spring-Integration 中将 SOAPAction header 添加到 HTTP 消息中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36046415/

相关文章:

java - SWT Filedialog 打开主文件夹

java - Spring中是否可以配置基于ConcurrentMap的缓存?

maven - Spring Integration 应用程序在作为打包的 jar 执行时不定义 channel

java - 无状态 session Bean 事务

java - 是否可以将内存文件放入 Camel 管道中?

Spring MVC ResponseBodyAdvice 用于在指定返回类型中添加 header

java - Controller 类中的 Spring MVC 本地化不起作用

java - Spring MQTT : catch ConnectException

Spring 批处理 : How to use spring batch to read file from sftp server and save it into database?

java - 使用 MapReduce 作业的 HBase 批量删除