是否有相当于客户端的EndpointInterceptorAdapter?

时间:2011-07-20 05:18:00

标签: spring-ws

客户端是否有等效的EndpointInterceptorAdapter?

因为我需要拦截来自客户端的传出和传入消息并与它们一起工作。

EndpointInterceptorAdapter仅拦截端点消息。

2 个答案:

答案 0 :(得分:0)

我认为你可以使用SmartEndpointInterceptor

public class SmartEndpointInterceptorImpl implements
    SmartEndpointInterceptor 
{

    public boolean handleRequest(MessageContext messageContext, Object endpoint)
        throws Exception 
    {
       SaajSoapMessage soapSaajMsg = (SaajSoapMessage)messageContext.getRequest();
       return true;
    }


    public boolean handleResponse(MessageContext messageContext, Object endpoint)
        throws Exception {

       return true;
    }

  //I omitted two more methods
}

答案 1 :(得分:0)

好吧,我找到了答案。 您必须创建一个实现ClientInterceptor的类。

package com.coral.project.interceptor;

public class WebServiceClientInterceptor implements ClientInterceptor {

@Override
public boolean handleRequest(MessageContext messageContext)
        throws WebServiceClientException {
    // TODO Auto-generated method stub
    return true;
}

@Override
public boolean handleResponse(MessageContext messageContext)
        throws WebServiceClientException {
    // TODO Auto-generated method stub
    return true;
}

@Override
public boolean handleFault(MessageContext messageContext)
        throws WebServiceClientException {
    // TODO Auto-generated method stub
    return false;
}
}

并在spring-ws配置文件中定义:

<bean id="crmClient" class="com.coral.project.clients.CrmClient">
    <property name="defaultUri" value="..."/>
    <property name="marshaller" ref="jaxb2Marshaller" />
    <property name="unmarshaller" ref="jaxb2Marshaller" />
    <property name="interceptors">
        <list>
            <bean class="com.coral.project.interceptor.WebServiceClientInterceptor" />
        </list>
    </property>
</bean>

就是这样。