0

当我在下面设置映射端点时,解析器customizeFault方法没有被命中。如果我删除它,它会被击中。有什么帮助吗?在我的解析器类中引发了异常。

MembershipManagementEndpoint.java

package com.openclass.adapter.ws;

@Endpoint
public class MembershipManagementEndpoint {

弹簧配置

<bean id="membershipExceptionResolver" class="com.openclass.adapter.ws.resolvers.LisMembershipResolverInterceptor">
        <property name="order" value="1"></property>
        <property name="mappedEndpoints">
            <set>
                <value>com.openclass.adapter.ws.MembershipManagementEndpoint</value>
            </set>
        </property>
    </bean>  

LisSoapFaultTranslatorExceptionResolver.java

    package com.openclass.adapter.ws.resolvers;
    public class LisMembershipResolverInterceptor extends LisSoapFaultTranslatorExceptionResolver {

@Override
    public boolean handleRequest(MessageContext messageContext, Object endpoint)
            throws Exception {

            throw new LisMembershipException();

        return true;
    }

LisSoapFaultTranslatorExceptionResolver.java

public abstract class LisSoapFaultTranslatorExceptionResolver extends
        SimpleSoapExceptionResolver implements SoapEndpointInterceptor {
4

1 回答 1

0

我添加为每个端点构建单独的拦截器/解析器,然后在拦截器/解析器中进行测试并测试正确的端点。

SoapFaultExceptionResolver

  @Override
    protected final boolean resolveExceptionInternal(MessageContext messageContext, Object endpoint, Exception ex) {

        MethodEndpoint methodEndpoint = (MethodEndpoint)endpoint;

        if(methodEndpoint != null && methodEndpoint.getBean().getClass().getSimpleName().equalsIgnoreCase(getEndpointClass().getSimpleName()))
            {
            Assert.isInstanceOf(SoapMessage.class, messageContext.getResponse(),
                    "SimpleSoapExceptionResolver requires a SoapMessage");
            SoapMessage response = (SoapMessage) messageContext.getResponse();
            String faultString = StringUtils.hasLength(ex.getMessage()) ? ex.getMessage() : ex.toString();
            SoapBody body = response.getSoapBody();
            SoapFault fault = body.addServerOrReceiverFault(faultString, getLocale());
            customizeFault(messageContext, endpoint, ex, fault);
            return true;
        }

        return false;
    }

配置

<bean id="courseSectionExceptionResolver" class="com.test.adapter.ws.resolvers.LisCourseSectionResolverInterceptor">
        <property name="order" value="1"></property>
    </bean>  

    <bean id="personExceptionResolver" class="com.test.adapter.ws.resolvers.LisPersonResolverInterceptor">
        <property name="order" value="2"></property>
    </bean> 

    <bean id="membershipExceptionResolver" class="com.test.adapter.ws.resolvers.LisMembershipResolverInterceptor">
        <property name="order" value="3"></property>
    </bean> 

    <bean id="bdemsExceptionResolver" class="com.test.adapter.ws.resolvers.LisBdemsResolverInterceptor">
        <property name="order" value="4"></property>
    </bean>  

    <bean id="outcomeExceptionResolver" class="com.test.adapter.ws.resolvers.LisOutcomeResolverInterceptor">
        <property name="order" value="5"></property>
    </bean>  

    <sws:interceptors>
        <sws:payloadRoot namespaceUri="http://www.imsglobal.org/services/lis/cmsv1p0/wsdl11/sync/imscms_v1p0">
            <bean class="com.test.adapter.ws.resolvers.LisCourseSectionResolverInterceptor"/>
        </sws:payloadRoot>
        <sws:payloadRoot namespaceUri="http://www.imsglobal.org/services/lis/pms2p0/wsdl11/sync/imspms_v2p0">
            <bean class="com.test.adapter.ws.resolvers.LisPersonResolverInterceptor"/>
        </sws:payloadRoot>
        <sws:payloadRoot namespaceUri="http://www.imsglobal.org/services/lis/mms2p0/wsdl11/sync/imsmms_v2p0">
            <bean class="com.test.adapter.ws.resolvers.LisMembershipResolverInterceptor"/>
        </sws:payloadRoot>
        <sws:payloadRoot namespaceUri="http://www.imsglobal.org/services/lis/bdems1p0/wsdl11/sync/imsbdems_v1p0">
            <bean class="com.test.adapter.ws.resolvers.LisBdemsResolverInterceptor"/>
        </sws:payloadRoot>
        <sws:payloadRoot namespaceUri="http://www.imsglobal.org/services/lis/oms1p0/wsdl11/sync/imsoms_v1p0">
            <bean class="com.test.adapter.ws.resolvers.LisOutcomeResolverInterceptor"/>
        </sws:payloadRoot>
        <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor">
            <property name="logRequest" value="true"/>
            <property name="logResponse" value="true"/>
        </bean>
    </sws:interceptors>
于 2013-04-09T20:54:13.363 回答