Jump to content

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.

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.

Edited by AbraCadaver
$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.

Edited by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.