尝试在现有Web服务上实现Method Argument Resolver

时间:2014-02-26 17:25:45

标签: spring spring-mvc

我们目前有一个包含此代码的端点:

@PayloadRoot(namespace = "http://predictivesolutions.com/schema/generated/v1_0", localPart = "ContactInsertRequest")
    public @ResponsePayload ContactInsertResponse handleInsert(@RequestPayload ContactInsertRequest request, MessageContext context) {}

但是,我们需要使用自定义数据类型,以便签名为:

@PayloadRoot(namespace = "http://predictivesolutions.com/schema/generated/v1_0", localPart = "ContactInsertRequest")
    public @ResponsePayload ContactInsertResponse handleInsert(@RequestPayload ContactInsertRequest request, LoginContextDO loginContext) {}

我实现了一个MethodArgumentResolver来返回LoginContextDO并将folliwng添加到spring配置中:

<bean id="defaultMethodEndPointAdapter"
    class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
    <property name="methodArgumentResolvers">
        <list>
            <!-- must list all resolvers if declaring a endpoint adapter -->
            <bean class="com.ps.ws.endpoint.interceptor.LoginContextResolver"/>
            <bean class="org.springframework.ws.server.endpoint.adapter.method.jaxb.JaxbElementPayloadMethodProcessor"/>
            <bean class="org.springframework.ws.server.endpoint.adapter.method.MessageContextMethodArgumentResolver"/>
        </list>
    </property>
</bean>

然而,它无法正常工作,我不断获得以下堆栈跟踪:

java.lang.IllegalStateException: No adapter for endpoint [public com.predictivesolutions.schema.generated.v1_0.ContactInsertResponse com.ps.ws.endpoint.v1.ContactServiceEndPoint.handleInsert(com.predictivesolutions.schema.generated.v1_0.ContactInsertRequest,com.dbo2.pipeline.authentication.LoginContextDO)]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
    at org.springframework.ws.server.MessageDispatcher.getEndpointAdapter(MessageDispatcher.java:299)
    at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:232)
    at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:173)
    at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
    at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:59)
    at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:292)

我想我错过了一些小事,但不知道该怎么做。 UIf我删除defaultMethodEndpointAdapter并放回MessageConext参数,webservice工作正常。我是否需要以某种方式注释LoginContextDo参数?

0 个答案:

没有答案