Search code examples
springsoapwsdlspring-ws

Spring WS seems to ignore mapped endpoint


I'd like to add a consumable contract-first webservice to a Spring MVC application - the application is the webservice provider. In web.xml I added a second servlet which should take care of the requests:

<servlet>
    <servlet-name>webservices</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:/webservices-servlet.xml</param-value>
    </init-param>
    <init-param>
        <param-name>transformWsdlLocations</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>webservices</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>

webservices-servlet.xml contains:

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

<sws:static-wsdl id="yAdaptorService" location="/WEB-INF/wsdl/yAdapterService.wsdl" />

<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
    <property name="interceptors">
        <list>
            <bean
                class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
            <bean
                class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
                <property name="schema" value="/WEB-INF/wsdl/ResourceAdapter.xsd" />
                <property name="validateRequest" value="true" />
                <property name="validateResponse" value="true" />
            </bean>
        </list>
    </property>
    <property name="order" value="1" />
</bean>

When the application is deployed and started in Tomcat 7 the WSDL is deployed at http://localhost:8080/application/services/yAdapterService.wsdl

The relevant WSDL snippets:

<message name="pingRequest">
</message>
<message name="pingResponse">
</message>
<portType name="yAdaptor">
    <operation name="ping">
        <input message="tns:pingRequest"></input>
        <output message="tns:pingResponse"></output>
    </operation>
</portType>
<binding name="SoapBinding" type="tns:yAdapter">
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="ping">
        <wsdlsoap:operation soapAction="urn:webservice.y.x.com:wsdl/ping"/>
        <input>
            <wsdlsoap:body use="literal"/>
        </input>
        <output>
            <wsdlsoap:body use="literal"/>
        </output>
    </operation>
</binding>
<service name="yAdapterService">
    <port binding="tns:SoapBinding" name="yAdapterSoapPort">
        <wsdlsoap:address location="http://localhost:8080/application/services/yAdapterService"/>
    </port>
</service>

Setting logger to debug level, Tomcat tells me during startup:

09 Jan 2014 12:20:49,247 DEBUG org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping:105 - Mapped [{urn:webservice.x.com:wsdl}ping] onto endpoint [public void de.y.yAdapterService.ping()]

But when it comes to a simple ping-request via SOAP-UI

SOAPAction: urn:webservice.x.com:wsdl/ping

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body/>
</soapenv:Envelope>

to this endpoint

private static final String NAMESPACE_URI   = "urn:webservice.x.com:wsdl";

@Override
@PayloadRoot(localPart = "ping", namespace = NAMESPACE_URI)
public void ping()
{
    System.out.println("ping pong");
}

the mapped endpoint cannot be found

/* SOAP-UI REQUEST ON urn:webservice.x.com:wsdl/ping */
09 Jan 2014 12:21:44,808 DEBUG     org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:136 - Opening JPA EntityManager in OpenEntityManagerInViewFilter
09 Jan 2014 12:21:44,818 DEBUG org.springframework.security.util.FilterChainProxy:205 - Converted URL to lowercase, from: '/services/yadapterservice'; to: '/services/yadapterservice'
09 Jan 2014 12:21:44,818 DEBUG org.springframework.security.util.FilterChainProxy:212 - Candidate is: '/services/yadapterservice'; pattern is /services/**; matched=true
09 Jan 2014 12:21:44,818 DEBUG org.springframework.security.util.FilterChainProxy:165 -  has an empty filter list
09 Jan 2014 12:21:44,827 DEBUG org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter:114 - Accepting incoming [org.springframework.ws.transport.http.HttpServletConnection@63a595be] at [http://localhost:8080/application/services/yAdapterService]
09 Jan 2014 12:21:44,864 DEBUG org.springframework.ws.server.MessageTracing.received:171 - Received request [SaajSoapMessage]
09 Jan 2014 12:21:44,875 DEBUG org.springframework.ws.soap.server.SoapMessageDispatcher:278 - Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping@b64f867] has no mapping for request
09 Jan 2014 12:21:44,876  WARN org.springframework.ws.server.EndpointNotFound:241 - No endpoint mapping found for [SaajSoapMessage]
09 Jan 2014 12:21:44,877 DEBUG org.springframework.ws.transport.http.MessageDispatcherServlet:966 - Successfully completed request
09 Jan 2014 12:21:44,877 DEBUG org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:154 - Closing JPA EntityManager in OpenEntityManagerInViewFilter
09 Jan 2014 12:21:44,878 DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils:338 - Closing JPA EntityManager

What am I missing? Why is the initially mapped endpoint not found?


Solution

  • Finally I figured out that SOAP-UI used a wrong namespace when parsing the WSDL. The correct request message is:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:webservice.x.com:wsdl">
        <soapenv:Header/>
        <soapenv:Body>
            <urn:ping/>
        </soapenv:Body>
    </soapenv:Envelope>