2016-03-24 10 views
0

SOAPリクエストを処理するためにSimpleWebServiceInboundGatewayを使用します。ここSpring統合で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> 
    ... 

私のルータでメッセージ・オブジェクトがヘッダデータが含まれていません。ユーザー名とパスワードをどのように抽出できますか?

答えて

0

SOAPヘッダーをマップするには、カスタマイズされたDefaultSoapHeaderMapperをゲートウェイに追加する必要があります。どのヘッダーにマップするかを指定してマッパーをカスタマイズします。

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

マップするヘッダーは、ヘッダーの修飾されたQNameと一致する必要があります。 STANDARD_REQUEST_HEADERS(デフォルト)はSoapActionをマッピングします。

リプライヘッダーにも同様のマッピングがあります。

関連する問題