web-services - 带有 SimpleJaxWsServiceExporter 的 Spring Webservice

标签 web-services spring jax-ws

基于http://www.subshell.com/en/subshell/blog/article-Publishing-Webservices-with-Java-6-and-Spring-WS100.html我尝试在 Tomcat 7 上使用 SimpleJaxWsServiceExporter 运行 Webservice。

localhost:8081/WSTest/TourWS?wsdl 在浏览器中导致错误 404。

TourWS.java

@WebService
@SOAPBinding(style=Style.DOCUMENT)
public interface TourWS {
@WebMethod
public void declareTours(ArrayList<TourWSEntity> tours);
@WebMethod
public void declareTour(TourWSEntity tour);
@WebMethod
public String whoAmI();

TourWSImpl.java

@WebService(serviceName="TourWS")
public class TourWSImpl implements TourWS {
public TourWSImpl(){}

@Override
public void declareTours(ArrayList<TourWSEntity> tours) {
    // impl
}

@Override
public void declareTour(TourWSEntity tour) {
    // impl
}

@Override
public String whoAmI(){
    return "JAX-WS Web Service - TourWS";
}

spring-ws-servlet.xml

<beans ...>
<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
    <property name="baseAddress" value="http://localhost:8081/" />
</bean>
<bean id="tourWSImpl" class="tour.spring.ws.impl.TourWSImpl" />
</beans>

网络.xml

<web-app ...>
<servlet>
    <servlet-name>spring-ws</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>spring-ws</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>

pom.xml

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>

控制台输出:

2012-06-17 22:29:52 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk\bin;.;...
2012-06-17 22:29:52 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:WSSpring' did not find a matching property.
2012-06-17 22:29:52 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
2012-06-17 22:29:52 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
2012-06-17 22:29:52 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 572 ms
2012-06-17 22:29:52 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
2012-06-17 22:29:52 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.6
2012-06-17 22:29:53 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
2012-06-17 22:29:53 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
2012-06-17 22:29:53 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
2012-06-17 22:29:53 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
2012-06-17 22:29:53 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
2012-06-17 22:29:53 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
2012-06-17 22:29:53 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
2012-06-17 22:29:53 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
2012-06-17 22:29:53 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
2012-06-17 22:29:53 org.apache.catalina.startup.Catalina start
INFO: Server startup in 799 ms
2012-06-17 22:29:54 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring-ws'
2012-06-17 22:29:54 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring-ws': initialization started
2012-06-17 22:29:54 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'spring-ws-servlet': startup date [Sun Jun 17 22:29:54 CEST 2012]; root of context hierarchy
2012-06-17 22:29:54 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-ws-servlet.xml]
2012-06-17 22:29:55 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3ca754: defining beans [org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter#0,tourWSImpl]; root of factory hierarchy
2012-06-17 22:29:55 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class tour.spring.ws.impl.jaxws.DeclareTours
2012-06-17 22:29:55 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class tour.spring.ws.impl.jaxws.DeclareToursResponse
2012-06-17 22:29:55 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class tour.spring.ws.impl.jaxws.DeclareTour
2012-06-17 22:29:55 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class tour.spring.ws.impl.jaxws.DeclareTourResponse
2012-06-17 22:29:55 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class tour.spring.ws.impl.jaxws.WhoAmI
2012-06-17 22:29:55 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class tour.spring.ws.impl.jaxws.WhoAmIResponse
2012-06-17 22:29:55 org.springframework.ws.soap.saaj.SaajSoapMessageFactory afterPropertiesSet
INFO: Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
2012-06-17 22:29:55 org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring-ws': initialization completed in 1125 ms

请告诉我可能有什么问题。

最佳答案

试试这个:localhost:8081/TourWS?wsdl 因此从地址中删除 WSTest

关于web-services - 带有 SimpleJaxWsServiceExporter 的 Spring Webservice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11074853/

相关文章:

java - 从消息响应中删除 soap header

java - 带有命名参数的 hibernate 查询没有给出结果

java - 如何在 websphere 上部署同一个 web 服务的多个版本

java - Jaxb:将参数传递给@XmlJavaTypeAdapter

java - 从 SQL Exception 对象获取引发异常的字段和表名称

java - weblogic 10.3.1 上的 jaxws 2.1.5 而不是预安装的 jaxws 2.1.1?

web-services - 获取 SharePoint 文档库级别的安全用户 PowerShell

java - Eclipse 生成的 Web 服务客户端非常慢

.net - 如何在构建时自动更新 Web 引用?

java - Maven 构建从 WEB-INF 文件夹中排除一些 .xml 文件