【问题标题】:xpath error: null on jaxb external bindings filexpath 错误:jaxb 外部绑定文件中为空
【发布时间】:2014-07-08 11:45:29
【问题描述】:

我正在尝试使用 wsimport 为外部 Web 服务的客户端生成 java 代码。

我创建了一个外部绑定文件,因为有重复的属性名称阻止 wsimport 工作。我收到一个错误 xpath error: null on line 4

这是我的绑定文件:

<jxb:bindings version="2.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<jxb:bindings wsdlLocation="http://XXXXX.net/WebService/XXXXX.chc?wsdl" node="/xs:schema">

<jxb:bindings node="//xs:element[@name='elementname']">
    <jxb:bindings node="//xs:element[@name='Option']">
        <jxb:bindings node="//xs:complexType">
            <jxb:bindings node=".//xs:attribute[@name='value']">
                <jxb:property name="ValueToFixError1" />
            </jxb:bindings>
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>

我尝试用 schemaLocation 替换 wsdlLocation 并得到一个不同的错误: “http://XXXXX.net/WebService/XXXXX.chc?wsdl”不是本汇编的一部分。这是“http://XXXXX.net/WebService/XXXXX.chc?wsdl#types?schema1”的错误吗?也在第 4 行,但是将 #types?schema1 添加到 url 只会让我回到原来的错误。

所以我尝试按照建议使用 jaxws,但我遇到了同样的错误:

<jaxws:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
wsdlLocation="http://XXXXX.net/WebService/XXXXX.chc?wsdl">
    <jaxws:bindings node="//definitions/types/xs:schema">
    <jaxb:bindings node="//xs:element[@name='elementname']">
        <jaxb:bindings node="//xs:element[@name='Option']">
            <jaxb:bindings node="//xs:complexType">
                <jaxb:bindings node=".//xs:attribute[@name='value']">
                    <jaxb:property name="ValueToFixError1" />
                </jaxb:bindings>
            </jaxb:bindings>
        </jaxb:bindings>
    </jaxb:bindings>
    </jaxws:bindings>
</jaxws:bindings>

编辑:添加部分 wsdl:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:cc" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:cc">
<types>
    <xs:schema targetNamespace="urn:cc" xmlns:cc="urn:cc" elementFormDefault="qualified" attributeFormDefault="qualified">    

【问题讨论】:

    标签: java xpath jaxb jax-ws wsimport


    【解决方案1】:

    使用 apache cxf 而不是 wsimport 解决了我的问题,但在我最初的方法中也存在一些问题。

    这就是最终奏效的方法:

    <jxb:bindings version="2.0" 
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    wsdlLocation="http://XXXXX.net/WebService/XXXXX.chc?wsdl"
    node="//xs:schema">
    
    <jxb:bindings node="//xs:element[@name='elementname']//xs:element[@name='Option']//xs:complexType">
        <jxb:bindings node=".//xs:attribute[@name='value']">
          <jxb:property name="ValueToFixError1" />
        </jxb:bindings>
    </jxb:bindings>
    </jxb:bindings>
    

    节点不应该嵌套,而是全部在一行上使用 //.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-12
      • 1970-01-01
      • 2014-10-30
      • 1970-01-01
      相关资源
      最近更新 更多