spring-ws:找不到端点映射
Posted
技术标签:
【中文标题】spring-ws:找不到端点映射【英文标题】:spring-ws: no endpoint mapping found 【发布时间】:2014-12-06 09:29:59 【问题描述】:我做了一个简单的网络服务,但是当我试图在soapui上测试它时,它给出了这个错误:
WARN : [Oct-11 12:56:38,081] ws.server.EndpointNotFound - No endpoint mapping found for [SaajSoapMessage http://www.servesy.com/api/v1/servicesignupRequest]
我不知道该怎么做才能使它正确,我看到了很多关于这个问题的问题,但没有找到任何解决方案。
我的 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 给出了这种类型的空白输出:
【问题讨论】:
【参考方案1】:对于它的价值,我在关注 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/producing-web-service/- 是我不知何故错过了用 @Endpoint public class CountryEndpoint
注释端点
【讨论】:
【参考方案2】:上下文级别的参数也需要反映在 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>
【讨论】:
【参考方案3】:EndpointNotFoundException
出现在 Spring-WS 找不到合适的 @Endpoint
可以处理传入请求时。
在这种情况下,传入消息具有命名空间http://www.servesy.com/api/v1/service
和本地名称signupRequest
(如日志中所示)。虽然您的 @PayloadRoot
映射确实具有相同的命名空间;它没有相同的本地名称,因为它使用带有大写 S 的 SignupRequest
。如果您在 @PayloadRoot
注释中将大写 S 更改为小写 s,它可能会起作用。
【讨论】:
以上是关于spring-ws:找不到端点映射的主要内容,如果未能解决你的问题,请参考以下文章