1 Reply Latest reply on Dec 19, 2007 9:39 PM by Diavanz

    Problem decoding array type from generate webservice stub

    heidi.hunter
      I've imported several WSDLs using the wizard, and the results have been satisfactory for simple types in most cases. However, I'm having trouble with decoding an array type which is a member of a complex type, where the array elements are decoded correctly (as far as I can tell) but the Array is never created.

      The relevant part of the WSDL looks like this:

      <s:complexType name="ArrayOfMyObject">
      <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="Item" nillable="true" type="tns:MyObject" />
      </s:sequence>
      </s:complexType>
      <s:complexType name="MyObject">
      <s:complexContent mixed="false">
      <s:extension base="tns:BaseEntityOfMyObject">
      <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="MyOtherObjects" type="tns:ArrayOfMyOtherObject" />
      <s:element minOccurs="1" maxOccurs="1" name="Status" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
      <s:element minOccurs="1" maxOccurs="1" name="ID" type="s:int" />
      </s:sequence>
      </s:extension>
      </s:complexContent>
      </s:complexType>
      <s:complexType name="BaseEntityOfMyObject" abstract="true" />
      <s:complexType name="ArrayOfMyOtherObject">
      <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="MyOtherObject" nillable="true" type="tns:MyOtherObject" />
      </s:sequence>
      </s:complexType>
      <s:complexType name="MyOtherObject">
      <s:complexContent mixed="false">
      <s:extension base="tns:BaseEntityOfMyOtherObject">
      <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="ID" type="s:int" />
      <s:element minOccurs="1" maxOccurs="1" name="SomeAttribute" type="s:int" />
      </s:sequence>
      </s:extension>
      </s:complexContent>
      </s:complexType>
      <s:complexType name="BaseEntityOfMyOtherObject" abstract="true" />

      By tracing in the debugger, I'm seeing that the constructor for the generated class MyOtherObject is called the correct number of times based on the result contents, but the constructor for ArrayOfMyOtherClass is never called. The resulting MyObject instance has all properties set except for the array, which is null.

      Curiously, the SOAP result, which is an ArrayOfMyObject, is decoded correctly. Does anyone have any thoughts on this?

      A possibly related question I've had is with the use of SchemaTypeRegistry. As I said, I'm importing multiple WSDLs. All are generated from the same server-side application, and so many of the types are shared between the services. All the services use the same namespace, so when the generated classes are registered with SchemaTypeRegistry, the QName objects are constructed identically. E.g.:

      In BaseService1.as:
      SchemaTypeRegistry.registerClass(new QName(" http://tempuri.org/","MyObject"),com.webservices.service1.MyObject);
      SchemaTypeRegistry.registerClass(new QName(" http://tempuri.org/","ArrayOfMyObject"),com.webservices.service1.ArrayOfMyObject);

      In BaseService2.as:
      SchemaTypeRegistry.registerClass(new QName(" http://tempuri.org/","MyObject"),com.webservices.service2.MyObject);
      SchemaTypeRegistry.registerClass(new QName(" http://tempuri.org/","ArrayOfMyObject"),com.webservices.service2.ArrayOfMyObject);

      I need to use different combinations of the services at once at runtime, so might this be affecting the type lookup during deserialization?

      Appreciate any info!