4 Replies Latest reply on Mar 9, 2008 8:19 PM by bitwyse

    Web Service result

    bitwyse Level 1
      Hi All,
      I'm looking for some assistance with the result of a webservice that contains an array of objects. That result is not being translated correctly by Flex, or I maybe I'm doing something wrong. Not sure. Below is the wsdl from my web service. Essentially, I have an expense report that should contains some basic data then an array of line items. I have also included the line item wsdl. When I watch the result of my web service with a trace utility, I can see the data just fine. However, when I see it in the Flex debugger, the array of Line Items get all messed up.

      I'm hoping someone has experience returning an array of object within a web service that can offer some assistance? A couple of additional items. I'm using Cairngorm and my web services return objects not e4x. I realize it would have been easier to use e4x however, I have to much code written to change it now.

      complexType name="ExpenseLineItem">
      <sequence>
      <element name="GLNo" nillable="true" type="xsd:string"/>
      <element name="b" nillable="true" type="xsd:string"/>
      <element name="cc" nillable="true" type="xsd:string"/>
      <element name="desc" nillable="true" type="xsd:string"/>
      <element name="eDate" nillable="true" type="xsd:string"/>
      <element name="extd" type="xsd:double"/>
      <element name="people" nillable="true" type="xsd:string"/>
      <element name="qty" type="xsd:double"/>
      <element name="rcpt" nillable="true" type="xsd:string"/>
      <element name="unit" type="xsd:double"/>
      </sequence>
      </complexType>

      <complexType name="ExpenseReport">
      <sequence>
      <element name="PPProjDBRepID" nillable="true" type="xsd:string"/>
      <element name="docID" nillable="true" type="xsd:string"/>
      <element name="lessCash" type="xsd:double"/>
      <element name="lessPaid" type="xsd:double"/>
      <element name="netDue" type="xsd:double"/>
      <element name="sfBranch" nillable="true" type="xsd:string"/>
      <element name="sfBranchManager" nillable="true" type="xsd:string"/>
      <element name="sfCompany" nillable="true" type="xsd:string"/>
      <element name="sfCreatedByCreated" nillable="true" type="xsd:string"/>
      <element name="sfDateSubmitted" nillable="true" type="xsd:string"/>
      <element name="sfDepartment" nillable="true" type="xsd:string"/>
      <element name="sfDepartmentManager" nillable="true" type="xsd:string"/>
      <element name="sfDirector" nillable="true" type="xsd:string"/>
      <element name="sfEmployeeID" nillable="true" type="xsd:string"/>
      <element name="sfFrom" nillable="true" type="xsd:string"/>
      <element name="sfOnBehalfOf" nillable="true" type="xsd:string"/>
      <element name="sfProjectBranch" nillable="true" type="xsd:string"/>
      <element name="sfProjectCompany" nillable="true" type="xsd:string"/>
      <element name="sfProjectDepartment" nillable="true" type="xsd:string"/>
      <element name="sfShow" nillable="true" type="xsd:string"/>
      <element name="sfTeamLeader" nillable="true" type="xsd:string"/>
      <element name="sfWeekEndingDate" nillable="true" type="xsd:string"/>
      <element name="tsClientLogRequired" nillable="true" type="xsd:string"/>
      <element name="tsTravelBookedBy" nillable="true" type="xsd:string"/>
      <element name="tsTravelReason" nillable="true" type="xsd:string"/>
      <element name="tspClientLog" nillable="true" type="xsd:string"/>
      <element name="tspCompany" nillable="true" type="xsd:string"/>
      <element name="tspDeliverable" nillable="true" type="xsd:string"/>
      <element name="tspProject" nillable="true" type="xsd:string"/>
      <element name="tspTask" nillable="true" type="xsd:string"/>
      <element name="viewCategory" nillable="true" type="xsd:string"/>
      <element name="webControlPublish" nillable="true" type="xsd:string"/>
      <element maxOccurs="unbounded" name="lineItems" nillable="true" type="impl:ExpenseLineItem"/>
      </sequence>
      </complexType>
        • 1. Re: Web Service result
          Gregory Lafrance Level 6
          From FB help:

          WebService and HTTPService components both return anonymous Objects and Arrays that are complex types. If makeObjectsBindable is true, which it is by default, Objects are wrapped in mx.utils.ObjectProxy instances and Arrays are wrapped in mx.collections.ArrayCollection instances.

          • 2. Re: Web Service result
            bitwyse Level 1
            Hey Greg,

            Thanks for the info. The problem I am having is that Flex is mangling the ArrayCollection that is being returned. I wish I could attach a pic to show you the debugger as it is very hard to describe . . .

            My object does have an array collection however, instead of having the correct items in the array collection it has a bunch of mangled data. For example, when I expand the mx.collections.arraycollection from within my objectProxy, I should see string's and dates. Instead I see things called ComplexStrings that can be expanded like an array. When I expand them I see my data. Worse yet is I should have a number of "line items" ( arrayCollection ) where each line item should have my data. As I work my way down the ComplexStrings I see other line items. It's really weird. I can't figure it out.

            It has to be a Flex issue as the data being returned is good valid XML as seen in my utility that captures my web traffic.
            • 3. Re: Web Service result
              ntsiii Level 3
              The default conversion of nice, clean xml into the nested object structure is a big black box.

              You made a *big* mistake not going with e4x to start with. Adobe did not help by making "object" the default.

              However much code you have, I advise changing. It will never get better, it will certainly get worse.

              Tracy
              • 4. Re: Web Service result
                bitwyse Level 1
                I hear you Tracy. I am trying now to convert it to e4x. I have a question.

                I have a function shown below that copies simple objects from one to another. It worked great for simple objects which were returned from my web service. Now that I am getting XML back, how do I copy that data to my VO? I do NOT want to copy each item one at a time from the xml. Is there some method to do this for me?

                ObjectTranslator.objectToInstance( model.getProjectControls.selectedProjectControlVO, event.data );