【问题标题】:How can I get Soap header in Spring integration?如何在 Spring 集成中获取 Soap 标头?
【发布时间】:2016-03-24 10:42:12
【问题描述】:

我使用 SimpleWebServiceInboundGateway 来处理 SOAP 请求。

这是我的一段代码:

@Router(defaultOutputChannel = "unsupportedOperation", inputChannel = "wsRequestChannel")
public String route(Message message) {
    String soapAction = (String)message.getHeaders().get(WS_SOAP_ACTION);
    ...
}

@Bean
public SimpleWebServiceInboundGateway wsInboundGateway(){
    SimpleWebServiceInboundGateway simpleWebServiceInboundGateway = new SimpleWebServiceInboundGateway();
    simpleWebServiceInboundGateway.setRequestChannelName("wsRequestChannel");
    simpleWebServiceInboundGateway.setReplyChannelName("wsResponseChannel");
    simpleWebServiceInboundGateway.setErrorChannelName("wsErrorChannel");
    return simpleWebServiceInboundGateway;
}

传入的soap信封包含一个soap头:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   <soapenv:Header>
      <myAuth>
         <username>user</username>
         <password>pass</password>
      </myAuth>
   </soapenv:Header>
   <soapenv:Body>
   ...

我的路由器中的 Message 对象不包含标头数据。如何提取用户名和密码?

【问题讨论】:

    标签: spring web-services soap spring-integration soapheader


    【解决方案1】:

    要映射 SOAP 标头,您需要在网关中添加自定义的DefaultSoapHeaderMapper;您可以通过告诉它要映射哪些标头来自定义映射器...

    mapper.setRequestHeaderNames("STANDARD_REQUEST_HEADERS", "myHeader");

    要映射的标头必须与标头的限定 QName 匹配。 STANDARD_REQUEST_HEADERS(默认)映射 SoapAction。

    回复标头也有类似的映射。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多