【问题标题】:wsimport bindings namespace errorwsimport 绑定命名空间错误
【发布时间】:2018-08-14 18:22:46
【问题描述】:

我正在尝试更改某些命名空间的包命名空间,因为它们有碰撞的对象。

这里是wsdl:

<wsdl:definitions 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/" 
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="https://localhost/DS/Search.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="https://localhost/DS/Search.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>  
</xsd:schema>
</wsdl:types>
</wsdl:definitions>

这里是绑定:

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               jaxb:version="2.0"
        wsdlLocation="https://localhost/DS/Search.svc?wsdl">
 <jaxb:bindings    node="//wsdl:definitions/wsdl:types/xsd:schema/xsd:import[@namespace='http://tempuri.org/']">
      <jaxb:schemaBindings>
        <jaxb:package name="directoryservice"/>
      </jaxb:schemaBindings>
    </jaxb:bindings>
 <jaxb:bindings   node="//wsdl:definitions/wsdl:types/xsd:schema/xsd:import[@namespace='http://localhost.datacontract.org/2004/07/Search.Models.SearchAPI']">
      <jaxb:schemaBindings>
        <jaxb:package name="directoryservice.model"/>
      </jaxb:schemaBindings>
    </jaxb:bindings>
</jaxb:bindings>

当我使用 -b 选项运行 wsimport 时出现此错误

[ERROR] XPath evaluation of "//wsdl:definitions/wsdl:types/xsd:schema/xsd:import[@namespace='http://tempuri.org/']" results in empty target node
  line 7 of file:service-bindings.xml

我得到两个绑定的错误..

我是否缺少绑定定义的内容?

【问题讨论】:

    标签: jaxb jax-ws wsimport


    【解决方案1】:

    我通过使用全局绑定找到了解决此问题的方法。绑定将创建服务 ObjectFactory,但不会创建模型 pojo。

    <?xml version="1.0" encoding="UTF-8"?>
    <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               jaxb:version="2.0">
    <jaxb:globalBindings generateElementProperty="false"/>
    </jaxb:bindings>
    

    【讨论】:

      猜你喜欢
      • 2016-03-06
      • 2016-04-11
      • 2010-09-09
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      • 1970-01-01
      • 2018-01-24
      • 2013-11-22
      相关资源
      最近更新 更多