Reading complex type element repeats first one found several times

Hi Experts.

I'm using Delphi XE6, using WSDL Importer with default options.

This is response I get from server:

    <group id="709">
      <fact term="Amount" value="141578823.7700" typ="Decimal"/>
      <fact term="Currency" value="RSD" typ="String"/>
    </group>
    <group id="709">
      <fact term="Amount" value="2854.2100" typ="Decimal"/>
      <fact term="Currency" value="USD" typ="String"/>
    </group>
    <group id="709">
      <fact term="Amount" value="42182.5000" typ="Decimal"/>
      <fact term="Currency" value="EUR" typ="String"/>
    </group>

Open in new window


(*Shortened for brewity*)


Everything gets read fine, except that for each of groups 709 I get only first group data. So I end up with:

    Data[1]=709/141578823.7700/RSD
    Data[2]=709/141578823.7700/RSD
    Data[3]=709/141578823.7700/RSD

Open in new window


instead of

    Data[1]=709/141578823.7700/RSD
    Data[2]=709/2854.2100/USD
    Data[3]=709/42182.5000/EUR

Open in new window


This is what WSDLImp gave me as a result:
      Fact = class(TRemotable)
      private
        Fterm: string;
        Fterm_Specified: boolean;
        Fvalue: string;
        Fvalue_Specified: boolean;
        Ftyp: string;
        Ftyp_Specified: boolean;
        procedure Setterm(Index: Integer; const Astring: string);
        function  term_Specified(Index: Integer): boolean;
        procedure Setvalue(Index: Integer; const Astring: string);
        function  value_Specified(Index: Integer): boolean;
        procedure Settyp(Index: Integer; const Astring: string);
        function  typ_Specified(Index: Integer): boolean;
      published
        property term:    string  Index (IS_ATTR or IS_OPTN) read Fterm write Setterm stored term_Specified;
        property value:   string  Index (IS_ATTR or IS_OPTN) read Fvalue write Setvalue stored value_Specified;
        property typ:     string  Index (IS_ATTR or IS_OPTN) read Ftyp write Settyp stored typ_Specified;
      end;
    
      Record = array of Fact;
    
      Group = class(TRemotable)
      private
        Fid: string;
        Fid_Specified: boolean;
        Ffact: Record;
        Ffact_Specified: boolean;
        procedure Setid(Index: Integer; const Astring: string);
        function  id_Specified(Index: Integer): boolean;
        procedure Setfact(Index: Integer; const ARecord: Record);
        function  fact_Specified(Index: Integer): boolean;
      public
        destructor Destroy; override;
      published
        property id:      string  Index (IS_ATTR or IS_OPTN) read Fid write Setid stored id_Specified;
        property fact:    Record  Index (IS_OPTN or IS_UNBD) read Ffact write Setfact stored fact_Specified;
      end;
    
      Array_Of_Group = array of Group;
    
      Main = class(TRemotable)
      private
        Fgroup: Array_Of_Group;
        Fgroup_Specified: boolean;
        procedure Setgroup(Index: Integer; const AArray_Of_Group: Array_Of_Group);
        function  group_Specified(Index: Integer): boolean;
      public
        destructor Destroy; override;
      published
        property group:  Array_Of_Group  Index (IS_OPTN or IS_UNBD) read Fgroup write Setgroup stored group_Specified;
      end;

Open in new window


Iterating through all Groups of Main, and reading all Facts, I get as I've mentioned only first set of facts that I come across repeated as many times as there is group with id=709.
So, my question is. What do I need to do in order to get all distinct groups and their values? What am I missing?
DPlayerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
Put some code how you access received soap response. Maybe you do something wrong.
DPlayerAuthor Commented:
It partially was. I found a workaround. It seems that Delphi treats id attribute as a unique identification string and simply copies first appearance into all instances that follow up with same id attribute.

Workaround is that for each id attribute I add an underscore and ordinal number after original id, thus creating it to be unique. Having done this made it unique and it all started working as expected. Of course I later had to remove that addendum and that is why I use underscore.

Thanks for contribution.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DPlayerAuthor Commented:
As I have said, I found a workaround.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.