Hello,

I am seeing an issue introduced with SDK 3.1 where the SDK is not properly
mapping XML schemas to AS classes.  We use the SchemaTypeRegistry magic to
have our AS classes instantiated based on the types contained in our SOAP
response.  We are seeing improper object creation, beginning in SDK 3.1, as
detailed below.

=====

AS Class:

public dynamic class UserType   {

        public var login:String="";
        public var Locale:LocaleType = new LocaleType();
        public var Flags:ArrayCollection = new ArrayCollection();
        
        public function UserType():void {
        }
}

Schema fragment:

<xsd:simpleType name="AccessFlagType">
  <xsd:restriction base="xsd:string">
    <xsd:minLength value="1"></xsd:minLength>
    <xsd:maxLength value="20"></xsd:maxLength>
  </xsd:restriction>
</xsd:simpleType>


<xsd:complexType name="AccessFlagsType">
  <xsd:sequence>
    <xsd:element name="Flag" type="hhl-User:AccessFlagType" minOccurs="0"
maxOccurs="unbounded"></xsd:element>
  </xsd:sequence>
</xsd:complexType>


<xsd:complexType name="UserType">
  <xsd:sequence minOccurs="1" maxOccurs="1">

    <xsd:element name="login" maxOccurs="1">
      <xsd:simpleType>
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="10" />
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:element>
    <xsd:element name="Locale" type="hhl-common:LocaleType" minOccurs="1"
maxOccurs="1"></xsd:element>
    <xsd:element name="Flags" type="hhl-User:AccessFlagsType"></xsd:element>
  
  </xsd:sequence>
</xsd:complexType>

XML:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:ns1="http://www.harte-hanks.com/hhl-User/";>
  <SOAP-ENV:Body>
    <authenticateResponse>
      <authenticated>true</authenticated>
      <UserInfo>
        <login>trainallac</login>
        <Locale>
          <countrycode>USA</countrycode>
          <languagecode/>
          <currencycode>USD</currencycode>
        </Locale>

        <Flags>
          <Flag>OESIMPORTORDERS</Flag>
          <Flag>ONESITE-ENGAGE_EDIT</Flag>
          <Flag>OES-FLEX</Flag>
          <Flag>OES-CREATE-BILLTO</Flag>
          <Flag>REPORTS</Flag>
        </Flags>
      </UserInfo>
    </authenticateResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

=====

What happens with SDK 2.1 is the UserType.Flags gets created as type
ArrayCollection, which has only one element.  This element is another
ArrayCollection instance which contains the flags.

If the Flags property is commented out of the class definition, the SDK will
"dynamically" create the Flags ArrayCollection and populate it with the
expected values.  Also, this issue does not exist with SDK 3.0 .  

In our real code, Flags is a subclass of ArrayCollection.  So the fix is not
as simple as just commenting out the formal definition for Flags and letting
the SDK create the property itself, since the SDK will then create an instance
of ArrayCollection instead of our subclass.  In our real code, the bogus
nested Flags are both of the type of our class, so there's definitely
something sketchy going on here.  I haven't been able to come up with a good
workaround yet, so we're building against 3.0 SDK for the time being.

Thanks,
Jeff

Reply via email to