Re: Re: [SOAP] Complex Types problem

[email protected] (pothik)
Newsgroups php.soap
Message-ID <[email protected]>


Dani Castaños-2 wrote:
> 
> Ammarmar escribió:
>> Dnia 25-06-2007 o 09:44:54 "Dani Castaños" 
>> <[email protected]> napisał(a):
>>
>>> PHP CLIENT
>>> ==========
>>> $subscriber = array( 'age'   => (Integer) 27
>>>                    , 'email' => (String) '[email protected]'
>>>                    , 'name'  => (String) 'Dani'
>>>                    );
>>> ?>
>>>
>>
>> Here you create ComplexType param as an array.
>>
>>>
>>> PHP SERVER
>>> ==========
>>> function CreateSubscriber( $subscriber )
>>> {
>>>   $name  = $subscriber['name'];
>>>   $email = $subscriber['email'];
>>>   $age   = $subscriber['age'];
>>>    return 200;
>>> }//function CreateSubscriber( $name )
>>
>> Here you try to access this ComplexType also as an array. Because you 
>> created it as an array, it seems logical to do so.
>>
>> Well, it is not - ComplexType is in fact a counterpart of an object. 
>> While SOAPClient accepts arrays AND objects as a representation of 
>> ComplexType, SOAPServer will ALWAYS return object (specifically, 
>> StdClass object).
>>
>> To access the name, email, etc, simply access fields of such object:
>>
>> $name = $subscriber->name;
>> $email = $subscriber->email;
>> $age = $subscriber->age;
>>
>> To be consistent, try to operate on objects on both sides (cliant and 
>> server).
>>
>> E.g. on client side you would create subscriber like that:
>>
>> $subscriber = new StdClass();
>> $subscriber->name = "Dani";
>> $subscriber->email = "[email protected]";
>> $subscriber->age = 27;
>>
>> (StdClass is standard class for creating generic objects, provided by 
>> PHP)
>>
>> It is easier to make a mistake when using arrays on client side 
>> (especially when ComplexTypes are more complex :-) )
>>
>> Have fun!
>>
> Thank you very much!
> Yesterday I wast at home thinking about it, and I figure out the same 
> solution. I was just reading carefully the error returned, and I get the 
> '$subscriber->name' format instead of '$subscriber['name']'
> 
> -- 
> PHP Soap Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

Dear All
If there is more than one row return then how i will count how many row is
there

-- 
View this message in context: http://www.nabble.com/Complex-Types-problem-tp11282384p20264445.html
Sent from the Php - Soap mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.