java xpath错误:jaxb外部绑定文件上为null
我正在尝试使用wsimport为外部web服务的客户端生成java代码
我创建了一个外部绑定文件,因为存在重复的属性名称,阻止wsimport工作。我得到一个错误xpath错误:第4行为null
这是我的绑定文件:
<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行,但添加#类型?指向url的schema1只会让我回到最初的错误
因此,我尝试按照建议使用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">
# 1 楼答案
使用apachecxf代替wsimport解决了我的问题,但在我最初的方法中也有一些问题
以下是最终的效果:
节点不应该嵌套,而是全部嵌套在一行上以使用//