Solved

Delphi soap (return array)

Posted on 2016-09-08
6
26 Views
Last Modified: 2016-10-28
I just started to use Delphi,
I don't know how to iterate over arrays.
I already did the connection between Delphi and soap.
I want to get the name (for exemple Arnold ) and to set in a TForm1.Edit1Change
I know how to do when I get a string but I don't know for a array.


in wsdl, I get:
  ArrayOf_xsd_string = TArray<String>;

  customerCtrlPortType = interface(IInvokable)
  ['{3C177C7E-853B-10B9-0F41-CA0B073BBF64}']
    function  ViewCustomer(const id: Integer): ArrayOf_xsd_string; stdcall;
  end;

in PHP, I get:
  Array ( [1] => Array ( [first] => Schwarzenegger [last] => Arnold ) [2] => Array ( [first] => Stallone [last] => Sylvester ) )

in xml, I get:
<item>
      <key xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:int">1</key>
      <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:Map">
            <item>
                  <key xsi:type="xsd:string">first</key>
                  <value xsi:type="xsd:string">Schwarzenegger</value>
            </item>

            <item>
                  <key xsi:type="xsd:string">last</key>
                  <value xsi:type="xsd:string">Arnold</value>
            </item>
      </value>
</item>
<item>
      <key xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:int">2</key>
      <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:Map">
            <item>
                  <key xsi:type="xsd:string">first</key>
                  <value xsi:type="xsd:string">Stallone</value>
            </item>
            <item>
                  <key xsi:type="xsd:string">last</key>
                  <value xsi:type="xsd:string">Sylvester</value>
            </item>
      </value>
</item>



Can you please help me
0
Comment
Question by:luffy monkey d
  • 2
  • 2
6 Comments
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 250 total points
ID: 41789344
you are somewhat vague on what you need
there are so many ways to store a set of strings ...

i see some generics  usage in the other languages and i also see xml

using generics with a Tlist:
http://docwiki.embarcadero.com/CodeExamples/Berlin/en/Generics_Collections_TList_(Delphi)

i also see Array
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Structured_Types_(Delphi)#Arrays

and a generics array:
http://docwiki.embarcadero.com/CodeExamples/Berlin/en/Generics_Collections_TArray_(Delphi)

what are you trying to do ?
0
 

Author Comment

by:luffy monkey d
ID: 41789379
I will try the first (Tlist)
0
 

Author Comment

by:luffy monkey d
ID: 41789392
I started by

Delphi:
procedure TForm1.Button1Click(Sender: TObject);
var
    resultat : TArray<String>;
begin
    resultat := (HTTPRIO1 as customerCtrlPortType ).ViewCustomer(1);
    Edit1.Text := resultat[1];
end;

Open in new window

0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41790150
and ?
0
 
LVL 26

Assisted Solution

by:Sinisa Vuk
Sinisa Vuk earned 250 total points
ID: 41792905
This kind of arrays always start from (zero indexed). So...better use Low and High function to get bounds...
var
    resultat : ArrayOf_xsd_string;
    i:Integer;
begin
    resultat := (HTTPRIO1 as customerCtrlPortType ).ViewCustomer(1);
    for i:=Low(resultat) to High(resultat) do
    begin
       Memo1.Lines.Add(resultat[i]);
     end;

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question