Jump to content

Attempting to understand Win7 Webservice to linux client scenario


straygrey

Recommended Posts

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.

$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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.