【发布时间】: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