gpt4 book ai didi

java - Spring ws端点映射两次

转载 作者:行者123 更新时间:2023-12-01 11:38:59 25 4
gpt4 key购买 nike

对于给定的端点类,我收到此错误:

无法映射端点 [public org.iaws.data.model.Theaters iaws.ws.soap.resources.TheaterEndpoint.getTheaters(java.lang.String,java.lang.String) 抛出 java.sql.SQLException ] 注册 key [{http://iaws/ws/contractfirst/example}data]:已经有端点 [public org.iaws.data.model.Theaters iaws.ws.soap.resources.TheaterEndpoint.getTheaters(java.lang .String,java.lang.String) 抛出 java.sql.SQLException] 映射

为什么端点被映射两次?

@Endpoint
public class TheaterEndpoint {

private final static String NAMESPACE = "http://soap/ws/contractfirst/example";

@PayloadRoot(namespace = NAMESPACE, localPart = "data")
@Namespace(prefix="dt", uri = NAMESPACE)
@ResponsePayload
public Theaters getTheaters(
@XPathParam("/dt:data/dt:movieId") final String movieId,
@XPathParam("/dt:data/dt:location") final String location)
throws SQLException {
TheaterSearch data = new TheaterSearch(movieId, location);
if (data.getMovieId() == null && data.getLocation() == null) {
throw new IllegalArgumentException();
} else {
if (data.getMovieId() == null) {
return db.getTheaters(data.getLocation());
} else {
if (data.getLocation() == null) {
return db.getTheatersForMovie(data.getMovieId());
} else {
Theaters theaters = db.getTheatersForMovie(
data.getMovieId(), data.getLocation());
return theaters;
}
}
}
}

}

最佳答案

我一直在尝试解决类似的问题并且以下工作有效。

在 MessageDispatcherServlet(在我的例子中是 spring-ws-servlet.xml)中,我为端点类创建了一个 bean,并进行了组件扫描。 取出 bean

<?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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!--
enables support for endpoint annotation, as per spring docs.
Forums ask to use this along with component scan. See SWS Bug 702
<link>http://stackoverflow.com/questions/6198644/spring-3-sws2-difference-between-contextcomponent-scan-and-swsannotation</link>
-->
<sws:annotation-driven />

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

<sws:dynamic-wsdl id="holiday"
portTypeName="HumanResource"
locationUri="/holidayService/"
targetNamespace="http://mycompany.com/hr/definitions">
<sws:xsd location="/WEB-INF/schema/holiday.xsd"/>
</sws:dynamic-wsdl>

<!-- REMOVE THIS BEAN -->
<bean id="holidayEndpoint" class="com.pkg.endpint.HolidayEndpoint" />

</beans>

关于java - Spring ws端点映射两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29708827/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com