wsimport绑定名称空间错误

时间:2018-08-14 18:22:46

标签: jaxb jax-ws wsimport

我正在尝试更改某些名称空间的包名称空间,因为它们的对象会发生冲突。

这是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

两个绑定都出现错误。

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

1 个答案:

答案 0 :(得分:0)

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

<?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>