I am using a soap client in php to obtain information from a Soap service
I finally managed to get the call itself to work which is good news!
<?
$url = "MYURL";
$client = new SoapClient($url, array("trace" => 1, "exception" => 0));
$SOAPCall = "Method";
$SoapCallParameters = new stdClass();
$SoapCallParameters->webUserKey = 'Value1';
$SoapCallParameters->urn = 'Value2';
$obj = $client->Method($SoapCallParameters);
var_dump ($obj);
echo $obj->{'LastName'};
?>
The method returns via Dump
object(stdClass)#3 (1) { [["LastName"]=> string(10) "Test"} ]}
However the echo statement does not print the LastName property
What am I doing wrong? I have tried different combinations like putting the property into a string variable
I have tried other ways and its still not working
This method also does not work
$obj = $client->Method($SoapCallParameters);
$vars = get_object_vars($obj);
$arr = (array)$vars;
var_dump($arr);
$lastName = (string) $arr[0]["LastName"];
echo $lastName;
Doing a var_dump using the logic above gives
I can see from the var_dump that there are values in the response
array(2) {
["CheckRegistrationStatus_UrnResult"]=>
string(10) "MatchFound"
["result"]=>
object(stdClass)#4 (6) {
["Age"]=>
string(2) "21"
["FirstClaimClub"]=>
string(47) "VALUE"
["FirstName"]=>
string(6) "FIRSTNAME"
["LastName"]=>
string(10) "LASTNAME"
["Registered"]=>
bool(true)
["URN"]=>
string(7) "VALUE"
}
}
This now means that the way I am trying to reference last name is wrong
What is the correct syntax?
Paul
[but no closing(2), but only one property namedLastName?) or the length of strings (string(10)vs"Test"? Granted, non-printable characters can be an issue, but in that case you usually see at least one whitespace before or after the actual value. Check the source code view of this debug output, not what your browser made of it when it interprets it as HTML.)echo (string) $obj->LastName;. Might work, cannot guarantee.