129.13. 自定义标头和附加过滤
如果您需要提供标头或附加的自定义处理,请扩展现有的 BasicMessageFilter,并覆盖适当的方法或写入 MessageFilter 接口的品牌新实施。
要使用您的自定义过滤器,请在 spring 上下文中添加全局或本地消息过滤器。
- A)提供所有 Spring-WS 端点的全局自定义过滤器
<bean id="messageFilter" class="your.domain.myMessageFiler" scope="singleton" />
或者
- b)本地 messageFilter 直接在端点上,如下所示:
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*/ }