1

I'm developing a web-service implementation base on a wsdl. In a xsd linked to the wsdl there is a complex choice like this:

 <xs:sequence>
            <xs:choice>
                <xs:element name="BinaryTerm" type="TermType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
                <xs:element name="BinaryExpression" type="ExpressionType"/>
            </xs:choice>
            <xs:element name="Operator" type="SimpleOperatorType"/>
            <xs:choice>
                <xs:element name="BinaryTerm" type="TermType"/>
                <xs:element name="BinaryExpression" type="ExpressionType"/>
            </xs:choice>
        </xs:sequence>

Every time I generated the class implementation I obtain a class, ExpressionType, with a list of JAXBElement due to the duplicate name BinaryTerm and BinaryExpression. I've read a lot of thread suggesting to use bindings.xml with these options:

<jaxb:globalBindings generateElementProperty="false" fixedAttributeAsConstantProperty="true" choiceContentProperty="true">

But nothing changed in my ExpressionType class. Anyone can suggest how to manage this XSD related to WSDL. I can't change these definition files. Thanks, Andrea

Mahdi Karami
  • 64
  • 1
  • 9

1 Answers1

0

when I want to generate classes with no JAXBElement use this binding. test it.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    elementFormDefault="qualified" attributeFormDefault="unqualified"
    jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1">
    <xs:annotation>
        <xs:appinfo>
            <jaxb:globalBindings generateElementProperty="false">
                <xjc:serializable />
            </jaxb:globalBindings>
        </xs:appinfo>
    </xs:annotation>
</xs:schema>
Mahdi Karami
  • 64
  • 1
  • 9
  • Like I stated before I've just try with this option but dont work, same behaviour as before. – Andrea Carlo Ponte Mar 29 '21 at 12:46
  • you right Andrea. I tested it and I get JAXBElements. look at this comment. I think there is no way to run away from JAXBElement because of the choice element https://stackoverflow.com/a/31478362/9047449. – Mahdi Karami Mar 29 '21 at 13:44