For all X12 OTDs, including the three envelope OTDs (located in Sun SeeBeyond ⇒ OTD Library ⇒ X12 ⇒ envelope), if the incoming message cannot be parsed for example, if the OTD cannot find the ISA segment, then the unmarshal() method generates a com.stc.otd.runtime.UnmarshalException.
The cause of the UnmarshalException depends on which envelope threw the exception:
A com.stc.otd.runtime.UnmarshalException is thrown by X12InterchangeEnv (the X12 interchange envelope) on data with a duplicate IEA segment (or, for that matter, any extra segment data after a regular IEA segment) or a duplicate inner level GE segment, but not on data with a missing IEA segment or a missing inner level GE segment.
A com.stc.otd.runtime.UnmarshalException is thrown by "X12FunctionalGroupEnv (the X12 functional group envelope) on data with a duplicate GS segment (or, for that matter, any extra segment data after a regular GS segment), but not on data with a missing GS segment or a missing transaction set level SE segment, and not on data with one or more duplicate transaction set level SE segments.
A com.stc.otd.runtime.UnmarshalException is thrown by X12TransactionSetEnv (the X12 transaction set envelope) on data with one or more duplicate SE segments.
You can also use the isUnmarshalComplete() method on an OTD to verify whether the unmarshal() method completed its parsing successfully. Successful completion does not guarantee that the OTD instance is free of data errors within segments and composites, because elements are not unmarshaled until the first invocation of the leaf element getElementXxxx() method of a segment or composite. For more information, see On Demand Parsing
. Encountering this exception triggers an automatic background unmarshal of the entire segment. Note that the value returned by the isUnmarshalComplete() method is not influenced by the outcome of the automatic background unmarshal. Instead, its value reflects what was set by the explicit invocation of the unmarshal() method.