【问题标题】:Build a WS with Spring使用 Spring 构建 WS
【发布时间】:2010-10-13 12:16:18
【问题描述】:

我需要使用 Spring 3.0.4.RELEASE 创建一个 WS 以在带有 Axis2 的 Tomcat 中运行。我正在关注这个文档:http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-web-services-jaxws-export-ri(如果该段落可以称为“文档”)

好的,以下是详细信息:

java类:

package foo;
@WebService(serviceName="MyService")
public class MyService{
  @WebMethod  
  public String getString(){
    return "Hello StackOverflow";
  }  
}  

WEB-INF/spring-ws.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:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://jax-ws.dev.java.net/spring/core https://jax-ws.dev.java.net/spring/core.xsd  
    http://jax-ws.dev.java.net/spring/servlet https://jax-ws.dev.java.net/spring/servlet.xsd">

  <wss:binding url="/myService" service="#myService" />

  <ws:service id="myService"
    impl="foo.MyService" />

</beans>

WEB-INF/web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="myService" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>my Service</display-name>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring-ws.xml</param-value>
</context-param>
<!-- this is for Spring -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- these are for JAX-WS -->
<servlet>
    <servlet-name>jaxws-servlet</servlet-name>
    <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>jaxws-servlet</servlet-name>
    <url-pattern>/myService</url-pattern>
</servlet-mapping>

最后但同样重要的是,当我启动 tomcat 6.0.29 时的错误

Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://jax-ws.dev.java.net/spring/servlet]
Offending resource: ServletContext resource [/WEB-INF/spring-ws.xml]  

有人知道发生了什么吗?所有的配置都正确吗?有没有人有一个简单的(工作的)WS 来展示如何使用 Spring 部署一个 WS?

提前致谢

【问题讨论】:

    标签: web-services axis2 java-web-start spring-3


    【解决方案1】:

    我不久前也遇到过这个问题,发现问题出在“https://”上。将其更改回 http:// ,您应该一切顺利。但是,当您使用 http:// 时,您会在 eclipse 中收到架构验证错误,因为 eclipse 无法自动将架构 url 从 http:// 重定向到 https://。显然 netbeans 能够做到这一点。

    还有一件事。您还必须拥有 xbeans-spring。老实说,我认为这是一个非常愚蠢的依赖。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-05
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      • 2015-10-12
      • 1970-01-01
      • 1970-01-01
      • 2010-11-01
      相关资源
      最近更新 更多