简体   繁体   中英

need to use both @soapaction and @PayloadRoot in single application

We have a spring application in which we have web services which will use both PayloadRoot and SoapAction. Now we have configured the following code in webservice-ws-context.xml

<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
        <property name="interceptors">
            <list>
                <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
                <bean id="validatingInterceptor"  class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
                    <property name="schema" value="classpath:/xsd/common.xsd"/>
                    <property name="validateRequest" value="${uiconnect.ws.payload.validate.request}"/>
                    <property name="validateResponse" value="${uiconnect.ws.payload.validate.response}"/>
                </bean>
            </list>
</property>
</bean>

Now, we want to add code for soap action, but if we add the following code then it doesn't work. So, how we can give the "id" attribute to this bean and configure this bin for a particular web service. Or is there any other way to configure this? I tried to make custom endpointmapping but help is not available for this.

<bean class="org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping">
        <property name="interceptors">
            <list>
                <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
                <bean id="validatingInterceptor"  class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
                    <property name="schema" value="classpath:/xsd/common.xsd"/>
                    <property name="validateRequest" value="${uiconnect.ws.payload.validate.request}"/>
                    <property name="validateResponse" value="${uiconnect.ws.payload.validate.response}"/>
                </bean>
            </list>
        </property>
    </bean>

An easier way to configure it would be using custom namespace that Spring-WS provides:

First the component scan to ensure that @Endpoint annotated beans are found:

<context:component-scan base-package="..." />

The following will internally register the PayloadRootAnnotationMethodEndpointMapping and SoapActionAnnotationMethodEndpointMapping

<sws:annotation-driven  /> 

and to register interceptors:

<sws:interceptors>
    <bean id="validatingInterceptor"  class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
        <property name="schema" value="classpath:/xsd/common.xsd"/>
        <property name="validateRequest" value="${uiconnect.ws.payload.validate.request}"/>
        <property name="validateResponse" value="${uiconnect.ws.payload.validate.response}"/>
    </bean>
    <sws:payloadRoot namespaceUri="....">
        <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
    </sws:payloadRoot>
    <sws:soapAction value="...">
        <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
    </sws:soapAction>
</sws:interceptors>**

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM