hello! i have a function in my C# code that returns a string array.
and when i test my function in WCF Test Client i get

   Name            Value            Type
   (return)        length=4         System.String[]
   [0]             "DE"             System.String
   [1]             "DK"             System.String
   [2]             "NO"             System.String
   [3]             "SE"             System.String

code if i do var_dump on the function

object(stdClass)[2]
  public 'LandsKodComboBoxResult' => 
    object(stdClass)[3]
      public 'string' => 
        array (size=4)
          0 => string 'DE' (length=2)
          1 => string 'DK' (length=2)
          2 => string 'NO' (length=2)
          3 => string 'SE' (length=2)

My code so far

<?php
        $client = new SoapClient("http://localhost:8731/phpwcf/?wsdl");
        var_dump($client->MyFunction());
        $array = $client->MyFunction();
        echo $array[2]
    ?>

*
so how do i create a php string = this return array?

thank you
Dendei.

Recommended Answers

All 4 Replies

Is this what you want?

$response = $client->MyFunction();
$array = $response->string;

maybe :P i just want the my return string array
in a php string array

tested

<?php

    $client = new SoapClient("http://localhost:8731/phpwcf/?wsdl");
    var_dump($client->LandsKodComboBox());
    $response = $client->LandsKodComboBox();
    $array = $response->string;
    echo $array[2]

?>

should this work?

i get Notice: Undefined property: stdClass::$string in C:\wamp\www\test\KundGrundUppgifterDesign.php

Think I missed one, pretty difficult without being able to test:

$response = $client->MyFunction();
$array = $response->LandsKodComboBoxResult->string;

hehe yes everyone makes mistakes. How a person deals with their mistakes is a mark of their character ^^ and you are very helpfull and it works now.
Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.