1 Reply Latest reply on Mar 24, 2008 11:56 PM by

    Flex not marshalling a nested structure correctly

      <complexType name="A">
      <element name="attrs" type="string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
      <element name="rels" type="tns:A" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
      <element name="relName" type="string" />

      Above is the xsd snippet of my webService operation. Operation has one of the parameters of type A (above). On the flex side, I have an action script class B that has get/set functions for attrs, rels and relName. When I use an instance of this type as a parameter to the webService operation in flex, it sends only attrs and relName in the SOAPBody.

      I also tried adding following function in class B and using generic object one gets from extractObject function.

      public function extractObject()
      Object obj = new Object();
      obj.attrs = attrs;
      obj.relName = relName;
      var relsArray:Array = relsArray = new Array();
      for each(rel in rels)
      obj.rels = relsArray;

      Just one other weird behavior is following: Instead of programatically getting the generic object
      if I hardcode the steps to generate the Object instance, webservice call works fine.
      Something like

      var o:Object = new Object();
      o.attrs = attrs;
      o.relName = "xyz";
      var relsArray:Array = new Array();
      var rel:Object = new Object();
      rel.attrs = relAttrs;
      rel.relName = "A";
      o.rels = relsArray;

      Strangely enough, this works perfectly fine. The same when we do it using the method function extractObject, doesnt work.

      Can anyone please suggest a good way of handling nested data structures in a webservice call?