2016-03-24 56 views
0

我使用SimpleWebServiceInboundGateway处理SOAP请求。如何在Spring集成中获得肥皂标题?

这里是一块我的代码:

@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> 
    ... 

在我的路由器的消息对象不包含标题数据。我如何提取用户名和密码?

回答

0

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

mapper.setRequestHeaderNames(“STANDARD_REQUEST_HEADERS”,“myHeader”);

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

答复标题有类似的映射。