straygrey Posted September 24, 2013 Share Posted September 24, 2013 I have written the following code as a client on Linux in an attempt to understand how a webservice running on a Windows 7 PC works. <?php $client = new SoapClient("http://192.168.0.10/CISWebService/Mediamanager.asmx?WSDL"); $result = $client->GetSequenceNo(array()); $response_arr = objectToArray($result); // print_r($response_arr); var_dump($response_arr); // $arrlength=count($response_arr); // echo $arrlength; function objectToArray($d) { // var_dump($d); if (is_object($d)) { $d = get_object_vars($d); } var_dump($d); if (is_array($d)) { return array_map(__FUNCTION__, $d); } else { return $d; } } ?> I get the following returned and displayed via the two var_dump() calls. array(6) { ["iServerNo"]=> int(0) ["iClientNo"]=> int(0) ["bNoLimitDownload"]=> bool(false) ["dtStartDate"]=> string(19) "0001-01-01T00:00:00" ["dtEndDate"]=> string(19) "0001-01-01T00:00:00" ["dtServerTime"]=> string(19) "0001-01-01T00:00:00"}int(0)int(0)bool(false)string(19) "0001-01-01T00:00:00"string(19) "0001-01-01T00:00:00"string(19) "0001-01-01T00:00:00"array(1) { ["GetSequenceNoResult"]=> array(6) { ["iServerNo"]=> int(0) ["iClientNo"]=> int(0) ["bNoLimitDownload"]=> bool(false) ["dtStartDate"]=> string(19) "0001-01-01T00:00:00" ["dtEndDate"]=> string(19) "0001-01-01T00:00:00" ["dtServerTime"]=> string(19) "0001-01-01T00:00:00" }}I suspect that I need to extract the value of iServerNo and iClientNo from either the returned object or the array created by my copied code. My question is how do I get these values into individual variables? In other words I would like to populate $iServerNo and $iClientNo but do not understand how. Link to comment https://forums.phpfreaks.com/topic/282411-attempting-to-understand-win7-webservice-to-linux-client-scenario/ Share on other sites More sharing options...
AbraCadaver Posted September 24, 2013 Share Posted September 24, 2013 I have no idea what you're asking or why you are using that objectToArray() function. Just post a var_dump() of $result and ask what you want to do with it. Link to comment https://forums.phpfreaks.com/topic/282411-attempting-to-understand-win7-webservice-to-linux-client-scenario/#findComment-1451052 Share on other sites More sharing options...
Ch0cu3r Posted September 24, 2013 Share Posted September 24, 2013 $client->GetSequenceNo(array()); Appears to return an object which is assigned to $result variable. To access an objects property you'd use this format $object_name->property_name. A property is like a variable but it belongs to the object. As you want to get the iServerNo and iClientNo you could try echo $result->iServerNo . '<br />' . $result->iClientNo If you've not used objects/classes then you should read up on Object Orientated Programming (OOP for short). Here is an introduction Also no need for the objectToArray() function just use print_r or var_dump. Link to comment https://forums.phpfreaks.com/topic/282411-attempting-to-understand-win7-webservice-to-linux-client-scenario/#findComment-1451058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.