1

I have a problem with the following sequence of a wsdl file

                <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1" name="allowCaseWithNewContract" type="xsd:boolean">
                </xsd:element>
                <xsd:choice minOccurs="0">
                    <xsd:element name="validationError" type="mnp:ErrorType"/>
                    <xsd:element name="internalError" type="mnp:ErrorType"/>
                    <xsd:element name="businessError" type="mnp:ErrorType"/>
                    <xsd:element name="externalError" type="mnp:ErrorType"/>
                </xsd:choice>
            </xsd:sequence>

            <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1" name="allowCaseWithExistingContract" type="xsd:boolean">
                </xsd:element>
                <xsd:choice minOccurs="0">
                    <xsd:element name="validationError" type="mnp:ErrorType"/>
                    <xsd:element name="internalError" type="mnp:ErrorType"/>
                    <xsd:element name="businessError" type="mnp:ErrorType"/>
                    <xsd:element name="externalError" type="mnp:ErrorType"/>
                </xsd:choice>
            </xsd:sequence>


I tried to use jaxb binding customization :

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
              xmlns:xs="http://www.w3.org/2001/XMLSchema"
              xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
  <jxb:globalBindings>
    <xjc:simple />
  </jxb:globalBindings>
</jxb:bindings>

I'm trying to avoid jaxb - xjc from generating my fields as a List<JAXBElement<?>> validationErrorsAndAllowCaseWithExistingContractsAndInternalErrors, is there anyway I could accomplish that?

Iulian Rosca
  • 1,005
  • 4
  • 15
  • 30

2 Answers2

0

I advise you to simplify the schema if possible. I would put the allowCaseWithNewContract and allowCaseWithExistingContract as attributes in the enclosing element. I guess then, the remaining choice would have the type ErrorType.

bourbert
  • 308
  • 3
  • 14
0

I am not allowed to comment, but I believe this question has been solved here and here - basically your best shot is to use the JAXB2 Simplify Plugin as JAXB will prevent you from doing what you want as it wants the (de-)serialization to be consistent from XML to Java and back (i.e. you need to preserve the order).