I am using version 0_9_3_21 and having a problem with validation during the unmarshalling of a message which contains an optional repeating element.  The problem I believe lies in the generated descriptor class of the containing element.  If I unmarshall a message that does not contain the optional repeating element, the descriptor appears to be initializing the class anyway (example below is where BankInfo is the containing element and RefInfo is the optional repeating element):
 
            public java.lang.Object getValue( java.lang.Object object )
                throws IllegalStateException
            {
                BankInfo target = (BankInfo) object;
                if (target.getRefInfo().length == 0) {
                  target.addRefInfo(new RefInfo());

                }
                return target.getRefInfo();
            }

 
The message being marshalled looks like this:
 
<DepAcctId>
  <AcctId/>
  <AcctType/>
  <BankInfo/>
  <com.ebancllc:AcctPermId>17610938</com.ebancllc:AcctPermId>
  <com.ebancllc:ClientOrgServUnitId/>
</DepAcctId>

 
Even though the RefInfo element is not present (target.getRefInfo().length == 0), the call to the constructor creates an instance of the RefInfo class and validation takes place for that element.  The validation is failing because there are two element that are required within that element that do not exist.  I commented out the section that was creating the instance of the class - target.addRefInfo(new RefInfo()) - and all went well.  What effects would this patch to the descriptor have and what is the reason for creating a new instance of the RefInfo class?
 
Here is the portion of the schema that generated the descriptor:
 
<element name = "BankInfo" minOccurs = "0">
  <complexType>
    <sequence>
      <element name = "BankIdType" type = "string" minOccurs = "0"/>
      <element name = "BankId" type = "string" minOccurs = "0"/>
      <element name = "RefInfo" minOccurs = "0" maxOccurs = "unbounded">
        <complexType>
         <sequence>
           <element name = "RefType" type = "string"/>
           <element name = "RefId" type = "string"/>
          </sequence>
        </complexType>
      </element>
      <element name = "Name" type = "string" minOccurs = "0"/>
      ....
      <element name = "Country" type = "string" minOccurs = "0"/>
    </sequence>
  </complexType>
</element>


Lee Brackman
IS Programmer
Voice: (614)480-7761
Fax: (614)480-7725
Email: [EMAIL PROTECTED]

"I develop reusable software that may be
    customized to satisfy the needs of our clients"



Reply via email to