Spring WS - 找不到端点映射

时间:2013-10-27 15:12:46

标签: java jaxb wsdl spring-ws endpoint

我对SpringWS有点新意,我正在尝试使用一个简单的应用程序。

当我尝试向WS发送有效的SOAP请求时,我收到以下警告:

WARNING: No endpoint mapping found for [SaajSoapMessage {http://www.sws.com/schemas}LoginRequest]

spring-ws-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:sws="http://www.springframework.org/schema/web-services"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:oxm="http://www.springframework.org/schema/oxm"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd">

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

    <bean id="loginService" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
        <property name="wsdl" value="/WEB-INF/wsdl/login.wsdl"/>
    </bean>

    <bean id="loginServiceBean" class="com.springws.service.LoginService"/>

    <sws:annotation-driven marshaller="jaxb2Marshaller" unmarshaller="jaxb2Marshaller"/>

    <oxm:jaxb2-marshaller id="jaxb2Marshaller">
        <oxm:class-to-be-bound name="com.springws.model.LoginResponse"/>
        <oxm:class-to-be-bound name="com.springws.model.LoginRequest"/>
    </oxm:jaxb2-marshaller>

</beans>

静态WSDL:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:sch="http://www.sws.com/schemas"
             xmlns:tns="http://www.sws.com/wsdl/login.wsdl"
             targetNamespace="http://www.sws.com/wsdl/login.wsdl">

    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <xsd:import namespace="http://www.sws.com/schemas" schemaLocation="login.xsd"/>
        </xsd:schema>
    </wsdl:types>

    <wsdl:message name="LoginRequest">
        <wsdl:part name="body" element="sch:LoginRequest"/>
    </wsdl:message>
    <wsdl:message name="LoginResponse">
        <wsdl:part name="body" element="sch:LoginResponse"/>
    </wsdl:message>

    <wsdl:portType name="AreValidCredentialsPortType">
        <wsdl:operation name="AreValidCredentials">
            <wsdl:input message="tns:LoginRequest"/>
            <wsdl:output message="tns:LoginResponse"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="CredentialValidationSoapBinding" type="tns:AreValidCredentialsPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="AreValidCredentials">
            <soap:operation soapAction="AreValidCredentials"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="LoginService">
        <wsdl:port name="AreValidCredentialsPort" binding="tns:CredentialValidationSoapBinding">
            <soap:address location="http://localhost:8080/LoginService/"/>
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

XSD:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.sws.com/schemas">

    <xs:element name="LoginRequest">
        <xs:complexType>
            <xs:all>
                <xs:element name="username" type="xs:string"/>
                <xs:element name="password" type="xs:string"/>
                <xs:element name="email" type="xs:string"/>
            </xs:all>
        </xs:complexType>
    </xs:element>

    <xs:element name="LoginResponse">
        <xs:complexType>
            <xs:all>
                <xs:element name="message" type="xs:string"/>
            </xs:all>
        </xs:complexType>
    </xs:element>
</xs:schema>

终点:

@Endpoint
public class ValidateLoginEndpoint {

    @Autowired
    LoginServiceInterface loginService;

    @PayloadRoot(localPart = "LoginRequest", namespace = "http://www.sws.com/schemas")
    @ResponsePayload
    public LoginResponse areValidCredentials(@RequestPayload LoginRequest request) {
        System.out.println("been here done this");
        return loginService.validateLoginRequest(request);
    }

关于我做得不对的任何线索?

0 个答案:

没有答案