java - wsimport and WSDL with duplicate variables -
java - wsimport and WSDL with duplicate variables -
i'm trying run wsimport against wsdl file cannot modify. portion of wsdl looks this:
<xsd:complextype name="bapiitemex"> <xsd:sequence> <xsd:element name="itmnumber" type="n0:numeric6"/> <xsd:element name="poitmno" type="n0:char6"/> <xsd:element name="material" type="n0:char18"/> <xsd:element name="matentrd" type="n0:char18"/> <xsd:element name="shorttext" type="n0:char40"/> <xsd:element name="netvalue" type="n0:numeric15"/> <xsd:element name="currency" type="n0:cuky5"/> <xsd:element name="subtotal1" type="n0:numeric15"/> <xsd:element name="subtotal2" type="n0:numeric15"/> <xsd:element name="subtotal3" type="n0:numeric15"/> <xsd:element name="subtotal4" type="n0:numeric15"/> <xsd:element name="subtotal5" type="n0:numeric15"/> <xsd:element name="subtotal6" type="n0:numeric15"/> <xsd:element name="subtotal1" type="n0:decimal23.4"/> <xsd:element name="subtotal2" type="n0:decimal23.4"/> <xsd:element name="subtotal3" type="n0:decimal23.4"/> <xsd:element name="subtotal4" type="n0:decimal23.4"/> <xsd:element name="subtotal5" type="n0:decimal23.4"/> <xsd:element name="subtotal6" type="n0:decimal23.4"/> </xsd:sequence> </xsd:complextype>
wsimport unhappy due inclusion of multiple elements differ in case ('subtotal1' versus 'subtotal1', etc.). specific error is
java.lang.illegalargumentexception: trying create same field twice: subtotal1
in researching solution problem, tried running wsimport '-b-xautonameresolution' option, had no effect. seems other possible solution utilize external binding file explicitly tell wsimport how name variables. however, i'm having difficulty making work well. here binding file i'm attempting utilize 1 of duplicate variables:
<jxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <jxb:bindings node="//xsd:complextype[@name='bapiitemex']//xsd:element[@name='subtotal1']"> <jxb:property name="testsubtotal1"/> </jxb:bindings>
try might, wsimport doesn't seem understand i'm asking do. it's unhappy xpath syntax i'm using 'node' attribute, returning error:
xpath evaluation of "//xsd:complextype[@name='bapiitemex']//xsd:element[@name='subtotal1']" results in empty target node
suggestions how can persuade wsimport generate java classes me?
after more fumbling around, figured out how write binding file create things work. solution based largely on info found in this post.
note have 6 cases of element names differ in case. solution posted below resolves 1 of conflicts. remainder can resolved adding more internal <jaxws:bindings> elements.
<jaxws:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1" xmlns:xsd="http://www.w3.org/2001/xmlschema" wsdllocation="pricingdirectcall.wsdl"> <jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema[@targetnamespace='urn:sap-com:document:sap:soap:functions:mc-style']/xsd:complextype[@name='bapiitemex']/xsd:sequence/xsd:element[@name='subtotal1']"> <jaxb:property name="testsubtotal1"/> </jaxws:bindings>
the biggest hurdle had overcome fiddling 'node' attribute xpath right (the conflict acutally occuring in internal xsd within wsdl). after had resolved, needed create sure specified right <jaxb> element. specifying <jaxb:class> changes info type of generated variable, creating inner class specified name, not wanted. specifying <jaxb:property> changes name of generated variable, resolving duplicate name conflict.
java wsdl wsimport duplicates
Comments
Post a Comment