136.13. 自定义标头和附加过滤
如果您需要提供标头或附件的自定义处理,请扩展现有的 BasicMessageFilter,并覆盖适当的方法,或编写一个 MessageFilter 接口的新实现。
要使用您的自定义过滤器,请在 spring 上下文中添加全局或本地消息过滤器。
- a)为所有 Spring-WS 端点提供全局配置的全局自定义过滤器
<bean id="messageFilter" class="your.domain.myMessageFiler" scope="singleton" />
<bean id="messageFilter" class="your.domain.myMessageFiler" scope="singleton" />
or
- b)本地 messageFilter 直接在端点上,如下所示:
to("spring-ws:http://yourdomain.com?messageFilter=#myEndpointSpecificMessageFilter");
to("spring-ws:http://yourdomain.com?messageFilter=#myEndpointSpecificMessageFilter");
如需更多信息,请参阅 CAMEL-5724
如果要创建自己的 MessageFilter,请考虑在类 BasicMessageFilter 中覆盖默认的 MessageFilter 实现中的以下方法:
protected void doProcessSoapHeader(Message inOrOut, SoapMessage soapMessage) {your code /*no need to call super*/ } protected void doProcessSoapAttachements(Message inOrOut, SoapMessage response) { your code /*no need to call super*/ }
protected void doProcessSoapHeader(Message inOrOut, SoapMessage soapMessage)
{your code /*no need to call super*/ }
protected void doProcessSoapAttachements(Message inOrOut, SoapMessage response)
{ your code /*no need to call super*/ }