【问题标题】:sun-jaxws.xml - Loading wsdl and xsds from jarsun-jaxws.xml - 从 jar 加载 wsdl 和 xsds
【发布时间】:2014-03-17 04:50:53
【问题描述】:

我正在使用契约优先的方法来构建 JAX-WS Web 服务。客户端使用 wsdlLocation 属性从客户端 jar 中选择 wsdl 和 xsd 资源,如此 SO 答案 - https://stackoverflow.com/a/18323853/775467 中指定的那样。

是否可以在服务器端做同样的事情。即是否可以使用 wsdls 并从 sun-jaxws.xml 中的 jar 引用 xsds

<endpoint name='TestService'
        implementation='provider.server.AddNumbersImpl'
        wsdl='WEB-INF/wsdl/Test.wsdl'
        service='{http://example.org}TestService'
        port='{http://example.org}TestServicePort'
        url-pattern='/test'/>

我知道我可以像上面的 sn-p 那样引用 WEB-INF 目录中的 wsdls,但我不想将 wsdls 和 xsds 打包到 WAR 中,而是想从共享库中获取它们jar 部署到服务器的方式与客户端代码选择 wsdl 的方式相同。

【问题讨论】:

    标签: web-services wsdl jax-ws


    【解决方案1】:

    无法更改 wsdl 文件的位置。 sun-jaxws.xml 中的 wsdl 属性必须具有前缀“WEB-INF/wsdl”。否则 JAX-WS 会生成并发布一个新的 WSDL。如果你看一下 jaxws-ri 的源代码,你可以在 com.sun.xml.ws.transport.http.DeploymentDescriptorParser 类中找到实现,方法 getPrimaryWSDL:

    ...
    if (wsdlFile != null) {
            if (!wsdlFile.startsWith(JAXWS_WSDL_DD_DIR)) {
                logger.log(Level.WARNING, "Ignoring wrong wsdl={0}. It should start with {1}. Going to generate and publish a new WSDL.", new Object[]{wsdlFile, JAXWS_WSDL_DD_DIR});
                return null;
            }
    ...
    }
    

    【讨论】:

      猜你喜欢
      • 2010-10-20
      • 1970-01-01
      • 1970-01-01
      • 2019-01-02
      • 2013-05-08
      • 2017-06-16
      • 2019-04-28
      • 2012-09-16
      • 2014-08-01
      相关资源
      最近更新 更多