【问题标题】:Spring and Jax-WS : where are xsd schema?Spring 和 Jax-WS:xsd 模式在哪里?
【发布时间】:2010-11-09 15:53:06
【问题描述】:

在 spring 文件 applicationConfig.xml 中,JAX-WS 集成需要一些特定的模式。 我最近成功地使用了这些声明:

    [我必须删除所有网址(除了一个),因为这是我的第一个问题]

    文件以这些声明开头:
    <beans xmlns="http www.springframework.org/schema/beans" xmlns:xsi="http www.w3.org/2001/XMLSchema-instance" xmlns:aop="http www.springframework.org/schema/aop" xmlns:tx="http www.springframework.org/schema/tx" xmlns:context="http www.springframework.org/schema/context" 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 www.springframework.org/schema/aop http www.springframework.org/schema/aop/spring-aop.xsd http www.springframework.org/schema/tx http www.springframework.org/schema/tx/spring-tx.xsd http www.springframework.org/schema/context http www.springframework.org/schema/context/spring-context.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">
    (...)
    &lt;ws:service id="myService" bean="#myWS" /&gt;
    &lt;wss:binding url="/services/myws" service="#myService" /&gt;

    现在,网站 jax-ws.dev.java.net 发生迁移。找不到这些文件,我在 Tomcat 和 Eclipse 下有一些错误:

    org.xml.sax.SAXParseException: schema_reference.4: 无法读取架构文档 'https://jax-ws.dev.java.net/spring/core.xsd',因为 1) 找不到文档; 2) 文件无法读取; 3) 文档的根元素不是。

    有没有什么办法可以防止这个错误?

    谢谢

    【问题讨论】:

    • 嘿,我也面临同样的问题。你有解决办法吗?

    标签: web-services spring jax-ws


    【解决方案1】:

    最后我从 jaxws-spring-1.8.jar 中提取 XSD(用于 jax-ws 的库以与 Spring 一起使用)。 我将这些 XSD 放在 WEB-INF 目录下,就在 applicationContext.xml 附近。 我在这个文件中修改了模式的声明:

       http://jax-ws.dev.java.net/spring/core classpath:spring-jax-ws-core.xsd
       http://jax-ws.dev.java.net/spring/servlet classpath:spring-jax-ws-servlet.xsd
    

    我在这里看到了解决方案: Spring schemaLocation fails when there is no internet connection

    【讨论】:

      【解决方案2】:

      我想你正在使用 maven 进行构建?尝试将依赖项添加到 pom.xml

      <dependency>
            <groupId>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
            <version>2.1-1</version>
      </dependency>
      

      如果您没有使用 maven,请确保您的类路径中有 jax-ws 库。 http://java.net/projects/jax-ws

      【讨论】:

      • 这不是编译问题...我将所有库都放在了我的类路径中。在 Tomcat 下部署应用程序时会出现错误。我认为 spring 读取 applicationContext.xml 并尝试读取所有 XSD 架构。
      • 让它编译和添加一个 jar 到类路径是两件不同的事情。也就是说,在这种情况下对我有帮助的是添加了 &lt;groupId&gt;org.jvnet.jax-ws-commons.spring&lt;/groupId&gt;&lt;artifactId&gt;jaxws-spring&lt;/artifactId&gt; 的 maven 依赖项
      【解决方案3】:

      您不需要从 jaxws-spring jar 中提取 XSD。 您只需要确保您使用的 URL 对应于 jar 中 META-INF/spring.schemas 文件中的 URL

      它们的定义如下:

      http\://jax-ws.dev.java.net/spring/core.xsd=spring-jax-ws-core.xsd
      http\://jax-ws.dev.java.net/spring/servlet.xsd=spring-jax-ws-servlet.xsd
      http\://jax-ws.dev.java.net/spring/local-transport.xsd=spring-jax-ws-local-transport.xsd
      

      认为您只需要将 https 替换为 http。例如:

      <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-3.0.xsd
                http://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd
                http://jax-ws.dev.java.net/spring/servlet http://jax-ws.dev.java.net/spring/servlet.xsd>
      

      有关 spring.schemas 的更多信息,请参阅here

      【讨论】:

        猜你喜欢
        • 2013-06-14
        • 2014-12-15
        • 2012-10-22
        • 1970-01-01
        • 2017-03-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多