I'm trying to generate java code for a client for an external web service using wsimport.
I've created an external bindings file as there are repeated attribute names preventing wsimport from working. I'm getting an error xpath error: null on line 4
Here is my bindings file:
<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>
I tried replacing wsdlLocation with schemaLocation and get a different error: "http://XXXXX.net/WebService/XXXXX.chc?wsdl" is not a part of this compilation. Is this a mistake for "http://XXXXX.net/WebService/XXXXX.chc?wsdl#types?schema1"? also on line 4, but adding #types?schema1 to the url just gets me back to the original error.
So I've tried to use jaxws as suggested, but I'm coming up with the same error:
<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>
Edit: Adding part of the 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">
Using apache cxf instead of wsimport solved my problem, but there were also a few problems in my initial approach.
Here's what worked in the end:
<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>
The nodes should not have been nested, but all on one line to use //.