error when reading a variable in PHP Notice: Undefined property: stdClass :: $ Name

0

I am trying to read a webservices that is in SoapUI but the field that I am trying to read is not a unique name, that is to say that I have several fields with the same name this something to itself.

<get1:Wallet>
           <get1:Name>PROMOTIONAL BALANCE 1</get1:Name>
           <get1:PresentValue>0</get1:PresentValue>
           <get1:AvailableValue>0</get1:AvailableValue>
           <get1:ExpirationDate>2036-12-12T00:00:00-06:00</get1:ExpirationDate>
        </get1:Wallet>
        <get1:Wallet>
           <get1:Name>WELCOMEPACK</get1:Name>
           <get1:PresentValue>0</get1:PresentValue>
           <get1:AvailableValue>0</get1:AvailableValue>
           <get1:ExpirationDate>2036-12-31T18:00:00-06:00</get1:ExpirationDate>
        </get1:Wallet>

What I need is to read the PresentValue field, at this moment I can read the field if it is unique and I am doing it in the following way:

with the echo if you print the activationDate field because it is a single field but not the Name field. How could I solve this?

    
asked by alvaro Luciano Garcia Gaitan 30.03.2017 в 19:49
source

1 answer

1

It shows you that message because you are dealing with an object in this case your object contains an array but of type object that when your service brings you more than one result what you have to do to go through your result example:

foreach($array as $row)
{
  $row->nombre;
  ...
  ...
}

or convert your object to an array

$datosArray = (array)$webService;
    
answered by 30.03.2017 в 20:57