0
votes

I have a ws inbound gateway configuration, which accepts soap request. And I have configured a SoapEndpointInterceptor for the same.

<int-ws:inbound-gateway id="inboundWsGateway"  request-channel="requestChannel" mapped-request-headers="*" reply-channel="responseChannel" error-channel="errorChannel" />

<bean class="org.springframework.ws.server.endpoint.mapping.UriEndpointMapping">    
<property name="defaultEndpoint" ref="inboundWsGateway"/>
<property name="interceptors">
<array>
<ref bean="messageEndpointInterceptor"/>
</array>

</property>

in the MessageEndPointInterceptor.handleRequest() method, I am trying to get the soap header and add new element

public boolean handleRequest(final MessageContext messageContext, final Object endpoint) {
final SoapMessage soapRequestMessage = (SoapMessage) messageContext.getRequest();
final SoapHeaderElement soapHeaderElement = soapRequestMessage.getSoapHeader().addHeaderElement(qname);
}

Since the incoming soap request is not having any soap:header, soapRequestMessage.getSoapHeader() is returning null. Please let me know how to handle this scenario

1
Would be better to see more context. Some code, test-case to play from our side, config etc. Otherwise it's gonna be long story to figure out the and and come up with the fix. And there is a big chance that your question will be closed here without any answer for you. Just because it is badly formed. That's it. - Artem Bilan

1 Answers

0
votes

Your scenario isn't correct. You receive request, therefore you have to live with it as is. It is immutable, you can't modify it.

Consider some other hooks to provide that additional info, e.g. MessageHeaders after <int-ws:inbound-gateway>.

You can add new SoapHeaderElement only if you are the owner of the message, e.g. if you use SoapMessageFactory directly, or if you send a WebServise message.

Your inbound message modification looks like sacrilege :).