xpath - How to generate Java files from WSDL when 'lang' already defined? -


i'm trying turn wsdl file java code using wsimport running command (which should work anyone's machine):

wsimport https://webservices-uatprod.dhisco.com/otahoteldescriptiveinfo/web_services?wsdl -j-djavax.xml.accessexternaldtd=all -j-djavax.xml.accessexternalschema=all -b-xautonameresolution -xnocompile 

however, keep getting error:

[error] 'lang' defined   line 93 of http://www.w3.org/2001/03/xml.xsd  [error] (related above error) first definition appears here   line 43 of http://www.w3.org/2001/xml.xsd  [error] 'space' defined   line 102 of http://www.w3.org/2001/03/xml.xsd  [error] (related above error) first definition appears here   line 89 of http://www.w3.org/2001/xml.xsd  [error] 'base' defined   line 109 of http://www.w3.org/2001/03/xml.xsd  [error] (related above error) first definition appears here   line 113 of http://www.w3.org/2001/xml.xsd  [error] 'specialattrs' defined   line 117 of http://www.w3.org/2001/03/xml.xsd  [error] (related above error) first definition appears here   line 157 of http://www.w3.org/2001/xml.xsd 

i've spent hours googling try , find solution. i'm relatively convinced need specify binding file -b binding.xml flag.

however, i'm having hard time figuring out how create binding file. here's i've attempted:

binding.xml

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"               xmlns:xsd="http://www.w3c.org/2001/xmlschema"               xmlns:xs="http://www.w3.org/2001/03/xml.xsd"               jaxb:version="2.0">   <jaxb:bindings schemalocation="http://www.w3.org/2001/xml.xsd">     <jaxb:bindings node="//xs:attribute[@name='lang']">         <jaxb:property name="langattribute"/>     </jaxb:bindings>   </jaxb:bindings> </jaxb:bindings> 

then in place, try running binding file by:

wsimport https://webservices-uatprod.dhisco.com/otahoteldescriptiveinfo/web_services?wsdl -j-djavax.xml.accessexternaldtd=all -j-djavax.xml.accessexternalschema=all -b-xautonameresolution -xnocompile -b binding.xml 

and get:

[error] xpath evaluation of "//xs:attribute[@name='lang']" results in empty target node   line 6 of file:/users/name/git/foo/bar/src/main/resources/wsdl/binding.xml 

i've tried many other combinations of binding file's xpath... figure need rename attribute of elements 'lang' else, have been having hard time figuring out.

thanks in advance help!

solution update: got past error downloading schemas locally, , wherever there reference schemalocation="http://www.w3.org/2001/03/xml.xsd" , schemalocation="http://www.w3.org/2001/xml.xsd", edited xml point local copy of file on file system.

i.e. opened each *.xsd file there reference these files, , updated each line this:

<xsd:import namespace="http://www.w3.org/xml/1998/namespace" schemalocation="http://www.w3.org/2001/xml.xsd"/> 

to this:

<xsd:import namespace="http://www.w3.org/xml/1998/namespace" schemalocation="./xml.xsd"/> 

after that, able generate java classes using wsimport syntax above (did require 1 small binding file, related vendor-defined class).

you've bound xs prefix xml namespace http://www.w3.org/2001/03/xml.xsd, should bound xml schema namespace http://www.w3.org/2001/xmlschema:

xmlns:xs="http://www.w3.org/2001/xmlschema" 

another problem you'll face schema seem address xml.xsd via 2 different locations: http://www.w3.org/2001/xml.xsd , http://www.w3.org/2001/03/xml.xsd. lot fo duplicates. can try resolve them via catalogs like:

rewrite_system "http://www.w3.org/2001/03/" "http://www.w3.org/2001/" 

(and use -catalog.)

but i'm not sure work. in similar situation i've created full local copy of schemas needed compile , patched them use uniform schema locations.

i tried downloading schemas , xml files locally, not sure how tell wsimport local copies instead of going out internet. if have copy of xsd.xml locally... there way tell wsimport use instead of may find on internet?

i'm not sure wsimport done catalogs. assume you've downloaded schemas http://www.w3.org in directory w3c. you'll have catalog file

rewrite_system "http://www.w3.org/" "w3c/" 

then should able use catalog file via wsimport -catalog mycatalog.cat .... wsimport or underlying schema compiler xjc should http://www.w3.org/2001/xml.xsd schema w3c/2001/xml.xsd then.

however, i've never tried wsimport, routinely use maven-jaxb2-plugin.


Comments