2016-10-20 47 views
0

我有一個ws入站網關配置,它接受肥皂請求。我已經爲相同的配置了一個SoapEndpointInterceptor。添加SOAP標題彈簧集成

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

在MessageEndPointInterceptor.handleRequest()方法

,我試圖讓肥皂頭和添加新的元件

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

由於傳入的SOAP請求不具有任何皁:頭文件soapRequestMessage.getSoapHeader()返回null。請讓我知道如何處理這種情況

+0

會更好地看到更多的上下文。一些代碼,從我們這邊玩的測試用例,配置等等。否則,找出並找出修復將會是一個漫長的故事。而且很有可能你的問題在這裏沒有任何答案就會被關閉。只是因爲它形成不好。而已。 –

回答

0

您的情況是不正確的。 您收到請求,因此您必須照原樣處理。它是不可變的,你不能修改它。

考慮一些其他的鉤子來提供額外的信息,例如, <int-ws:inbound-gateway>之後的MessageHeaders

僅當您是郵件的所有者時,您纔可以添加新的SoapHeaderElement,例如,如果您直接使用SoapMessageFactory,或者發送WebServise消息。

您的入站郵件修改看起來像sacrilege :)。