Spring集成应该路由消息(使用SOAP头)

Spring集成应该路由消息(使用SOAP头),soap,spring-integration,Soap,Spring Integration,我正在尝试编写一个配置网关,它应该接受一个完整的SOAP消息,然后将它委托给另一个SOAP提供者,包括第一个请求的所有SOAP头 到目前为止我所做的: 1.web.xml MessageDispatcherServlet with Mapping: <servlet-mapping> <servlet-name>spring-ws</servlet-name> <url-pattern>/appservices/*</url-

我正在尝试编写一个配置网关,它应该接受一个完整的SOAP消息,然后将它委托给另一个SOAP提供者,包括第一个请求的所有SOAP头

到目前为止我所做的:

1.web.xml

MessageDispatcherServlet with Mapping:
<servlet-mapping>
    <servlet-name>spring-ws</servlet-name>
    <url-pattern>/appservices/*</url-pattern>
</servlet-mapping>
这是我的测试的SOAP消息:

<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:stat="http://status.service.promakler.provinzial.com/">

    <soapenv:Header>
        <myToken:MySecretToken xmlns="" 
      xmlns:myToken="http://foo.bar">12345</myToken:MySecretToken>
    </soapenv:Header>

    <soapenv:Body>
        <stat:getStatus/>
    </soapenv:Body>
</soapenv:Envelope>
所以现在我的消息中有了头,但是在ClientInterceptor中,没有办法得到头,只有有效负载?!我可以添加新的标题,但如何获取原始标题? 有谁能给我一个提示,或者也许有一个更简单的解决方案

问候
Timo

尝试引入DefaultSoapHeaderMapper的自定义扩展,并覆盖populateUserDefinedHeader,以从MessageHeader中提取这些SaaJSOApHeader元素并将其填充到SoapHeader中。最后将您的解决方案注入到的头映射器。

我尝试添加一个特殊的映射器来扩展DefaultSoapHeaderMapper,但从未调用populateUserDefinedHeader方法。当wire tap向我显示消息头时,这怎么可能呢?使用配置它我不知道为什么它不起作用,但我找到了一个解决方案:我重写fromHeadersToRequest方法并手动将其放入目标中。非常感谢!如果您只是想代理一些其他Web服务重新路由SOAP消息,那么您可能需要考虑使用基本的HTTP网关。加里,您能给我一个简短的例子或链接,我可以在其中找到一些信息吗?
<int-ws:inbound-gateway id="ws-in-gw" 
    request-channel="in" 
    reply-channel="out" 
    mapped-request-headers="*" />

<int:channel id="in" />

<int:channel id="out" />

<int-ws:outbound-gateway
    id="ws-out-gw-status"
    request-channel="in-status"
    reply-channel="out-status"
    uri="http://${delegationServer}/${delegation.contextroot}/soap/AnotherService"
    interceptor="soapEnricher"
</int-ws:outbound-gateway>

<bean id="soapEnricher" class="foo.bar.SoapHeaderEnricher" />


public class SoapHeaderEnricher implements ClientInterceptor {

@Override
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {

    try {
        SoapMessage soapMessage = (SoapMessage) messageContext.getRequest();
        SoapHeader sh = soapMessage.getSoapHeader();
        // can use sh.addHeaderElement(new QName(...)) now, but where are the original Headers???
    } catch () {
    }
}
DEBUG 10:46:53 - [Payload DOMSource content=javax.xml.transform.dom.DOMSource@24a6ce98][Headers={errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@43456ff4, myToken:MySecretToken=org.springframework.ws.soap.saaj.SaajSoapHeaderElement@3b91ead, ...}]
<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:stat="http://status.service.promakler.provinzial.com/">

    <soapenv:Header>
        <myToken:MySecretToken xmlns="" 
      xmlns:myToken="http://foo.bar">12345</myToken:MySecretToken>
    </soapenv:Header>

    <soapenv:Body>
        <stat:getStatus/>
    </soapenv:Body>
</soapenv:Envelope>