spring-ws:未找到端点映射

问题描述 投票:0回答:5

我做了一个简单的网络服务,但是当我尝试在soapui上测试它时,它给出了这个错误:

WARN : [Oct-11 12:56:38,081] ws.server.EndpointNotFound - No endpoint mapping found for [SaajSoapMessage {http://www.servesy.com/api/v1/service}signupRequest]

我不知道该怎么做才能使其正确,我看到了很多关于这个问题的问题,但没有找到任何解决方案。

我的spring-ws配置如下: (除了这个配置之外,我还尝试制作简单的输入输出示例 也显示相同的警告)

web.xml

<web-app 
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/config/servesy-config.xml
        </param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

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

    <servlet-mapping>
        <servlet-name>servesyservices</servlet-name>
        <url-pattern>*.wsdl</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>servesyservices</servlet-name>
        <url-pattern>/endpoints/*</url-pattern>
    </servlet-mapping>

</web-app>

servesy-config.xml

<beans 
    <context:component-scan base-package="com.servesy.webservices" />
    <sws:annotation-driven />


    <bean id="ServesyService" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition" lazy-init="true">
        <property name="schemaCollection">
            <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
                <property name="inline" value="true" />

                    <property name="xsds">
                        <list>
                            <value>schemas/ServesyServices.xsd</value>
                        </list>
                    </property>

            </bean>
        </property>
        <property name="portTypeName" value="ServesyService"/>
        <property name="serviceName" value="ServesyServices" />
        <property name="locationUri" value="/endpoints"/>
    </bean>
</beans>

端点

@Endpoint
public class ServesyWebServiceEndpoint {

        private static final String TARGET_NAMESPACE ="http://www.servesy.com/api/v1/service";


        private ServesyWebService servesyservice_i;

        @Autowired
        public void setServesyWebService(ServesyWebService servesyservice_p)
        {
            this.servesyservice_i = servesyservice_p;
        }



        @PayloadRoot(localPart="SignupRequest", namespace=TARGET_NAMESPACE)
        public @ResponsePayload SignupResponse response(SignupRequest signupRequest) {

            SignupResponse signupResponse = new SignupResponse();
            Signup signup = servesyservice_i.signupResponse( signupRequest.getMobileNumber(), signupRequest.getPassword(), signupRequest.getCustomerName(), signupRequest.getEmailId(), signupRequest.getPromoCode(), signupRequest.getDevice());
            signupResponse.setSignup(signup);
            return signupResponse;
        }

        @PayloadRoot(localPart="LoginRequest", namespace=TARGET_NAMESPACE)
        public @ResponsePayload LoginResponse response(LoginRequest loginRequest) {

            LoginResponse loginResponse = new LoginResponse();
            String string = servesyservice_i.signinResponse( loginRequest.getEmailID(), loginRequest.getPassword(), loginRequest.getDevice());
            loginResponse.setSessionId(string);
            return loginResponse;
        }
    }

我的 soupui 给出了这种类型的空白输出: enter image description here

spring web-services soapui spring-ws endpoint
5个回答
24
投票

当 Spring-WS 无法找到可以处理传入请求的合适

EndpointNotFoundException
时,就会出现
@Endpoint

在这种情况下,传入消息具有命名空间

http://www.servesy.com/api/v1/service
和本地名称
signupRequest
(如日志中所示)。虽然您的
@PayloadRoot
映射确实具有相同的命名空间;它没有相同的本地名称,因为它使用带有大写 S 的
SignupRequest
。如果您将
@PayloadRoot
注释中的大写 S 更改为小写 s,那么它可能会起作用。


2
投票

我也遇到过类似的问题,根本原因在于应用程序 servlet 上下文路径。

在我看来,解决此问题的最佳方法是为 “org.springframework.ws” 设置 DEBUG 日志记录级别并仔细观察日志。您应该会找到这样的消息:

o.s.w.s.e.mapping.UriEndpointMapping - Mapped key [/ws/CardInfoWS_v3] onto endpoint [bean 'cardInfoEndpointGateway_v3'; defined in: '...']

发送请求后警告说:

o.s.w.s.e.mapping.UriEndpointMapping - Looking up endpoint for [/cms-ws/ws/CardInfoWS_v3]
o.s.ws.server.EndpointNotFound - No endpoint mapping found for [SaajSoapMessage {...}GetCardRequest]

所以...它正在密钥 "/cms-ws/ws/CardInfoWS_v3" 下查找端点映射,但端点已在密钥 "/ws/CardInfoWS_v3" 下注册。

您还可以将断点放置在端点映射器(AbstractMapBasedEndpointMappingAbstractMethodEndpointMapping)中的方法lookupEndpoint中,如下所示:

protected Object lookupEndpoint(String key) {
    return endpointMap.get(key);
}

发送请求后,在调试模式下您将看到所有注册的端点当前搜索的密钥


0
投票

上下文级别参数也需要反映在 MessageDispatcherServlet 级别。

<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class> <br>
        <init-param> <br>
            <param-name>transformWsdlLocations</param-name> <br>
            <param-value>true</param-value> <br>
        </init-param> <br>
        <init-param> <br>
            <param-name>contextConfigLocation</param-name> <br>
            <param-value>/WEB-INF/config/servesy-config.xml</param-value> <br>
        </init-param> <br>


0
投票

不管怎样,我在关注时遇到了这个问题

2021-02-17 14:13:52.810 DEBUG 204429 --- [nio-8080-exec-7] o.s.w.soap.server.SoapMessageDispatcher  : Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping@7f98f516] has no mapping for request 
- https://spring.io/guides/gs/having-web-service/- 是我不知何故错过了用
 注释端点@Endpoint public class CountryEndpoint


0
投票

他们将其从大写更改为小写。感谢@Arjen Poutsma 提供的信息 enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.