0 Replies Latest reply on Sep 16, 2011 8:58 AM by jappetta

    Problem Passing Complex Object on Webservice call (Flex 4)

    jappetta
      I am attempting to pass a complex object for storage in a database
      I used the Data->Connect to Webservice tool to create service objects for passing to the database. The objects represented in the WSDL would be qualifed as deep/complex. Following is an excerpt from the wsdl (wdsl was created from java objects using 1.4):
      <complexType name="BuildObject">
      <sequence>    
      <element maxOccurs="unbounded" name="docsetComments" nillable="true" type="tns1:DocsetComment"/>    
      </sequence>
      </complexType>
      The "ConnectToWebservice Tool" creates the following actionscript class for BuildObject (edited for brevity)
      public class _Super_BuildObject extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
      {
      model_internal static function initRemoteClassAliasSingle(cz:Class) : void
      {
      }  

      model_internal static function initRemoteClassAliasAllRelated() : void
      {

      com.myPackage.valueObjects.DocsetComment.initRemoteClassAliasSingleChild();

      }
      /**
      * properties
      */

      private var _internal_docsetComments : ArrayCollection;
      private static var emptyArray:Array = new Array();

      /**
      * data property getters
      */


      [Bindable(event="propertyChange")]
      public function get docsetComments() : ArrayCollection   
      {
      return _internal_docsetComments;
      }
      /**
      * data property setters
      */

      public function set docsetComments(value:*) : void
      {    
      var recalcValid:Boolean = false;
      if (value == null || _internal_docsetComments == null)
      {
      recalcValid = true;
      }


      var oldValue:ArrayCollection = _internal_docsetComments;              
      if (oldValue !== value)
      {
      if (value is ArrayCollection)
      {
      _internal_docsetComments = value;
      }
      else if (value is Array)
      {
      _internal_docsetComments = new ArrayCollection(value);
      }
      else
      {
      throw new Error("value of docsetComments must be a collection");
      }
      this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "docsetComments", oldValue, _internal_docsetComments));
      }         

      if (recalcValid && model_internal::_cacheInitialized_isValid)
      {
      model_internal::isValid_der = model_internal::calculateIsValid();

      }
      }
      I create an instance of BuildObject class and do not specify a value for DocsetComments. When I check my object before calling the webservice, I see that buildObject.docsetComments = null (what I would expect). However, when I set a breakpoint in the java code that receives the xml and look at the resulting object, I see that the DocsetComment has been represented as a list created with a null entry (you could simulate this in java by creating a list of length=1 with nothing in it). Our webservice->java code fails with this representation. I did try specifying an empty ArrayCollection for the buildObject.docsetComments property but got the following message:
      "Value supplied for DocsetComment occurs 0 times which falls short of minOccurs = 1"
      So, not specifying a value for buildObject.docsetComments doesn't work for our java adapter and setting an empty ArrayCollection is not resolved
      correctly.
      I've read in previous posts related to Flex 3 that there were issues with complex objects as webservice parameters but according to those same posts, the issues were to be resolved in Flex 4. I'm trying to determine where my problem lies:
      Options
      1. service objects not created correctly from Data->Connect to Webservice?
      2. encoding problem for the generated actionscript class?
      3. wdsl not correct?
      4. and last but not least, user error?
      Your thoughts are greatly appreciated. I'm both new to Flex and webservices.