Reputation: 139
I am using ws:outbound-gateway to invoke soap service. I have added interceptor as well.
<int-ws:outbound-gateway id="wsOutboundGateway"
request-channel="requestChannel"
uri="{soapURI}"
message-sender="httpMessageSender"
message-factory="messageFactory"
interceptor="myInterceptor"
marshaller="jaxbMarshaller" unmarshaller="jaxbMarshaller">
<int-ws:uri-variable name="soapURI" expression="headers.soapURI"/>
</int-ws:outbound-gateway>
myInterceptor is a class which implements ClientInterceptor.
Query: I have the information in message header which needs to be intercepted. Is there any way to receive the message header in the interceptor.
Note : I am setting the header value in thread local and getting back in the interceptor now.
Any better solution, please suggest.
Upvotes: 1
Views: 666
Reputation: 121552
It depends of the premise and context.
Sorry, but you have to share more info. What is the header? What do you do with that? Maybe there is no need to intercept it in the ClientInterceptor
, but would be better even before <int-ws:outbound-gateway>
?
UPDATE
I have the info in message header where I have to pass it in the soap header.
Actually ClientInterceptor
is fully for different purpose and its intention do not modify the message.
There is WebServiceMessageCallback
abstraction for message modification before sending.
But having your requirements like pass SOAP header I can suggest you to take a look into out-of-the-box component like DefaultSoapHeaderMapper
. Its populateStandardHeaders
deal only with SoapAction
and populateUserDefinedHeader
populates only as soapHeader.addAttribute()
. So, consider some extension of that class to insert custom tags into soapHeader
. And already without any ThreadLocal
hacks.
Upvotes: 1