Re: [PHP-SOAP-DEV] bug storing the SoapObject in session
Status: Alpha
Brought to you by:
rodif_bl
|
From: andrey <ahr...@ic...> - 2002-05-13 09:42:33
|
I think I know what is the problem.
When object is serialiazed all it's properties are serialized but some
properties have no meaning after serialization. For example a class wrapper
for DB connection may have property $link (resource of type mysql) but this
link has meaning only on the page where it is created. If we serialize $link
there will be problem when deserialized. I don't know what is the solution
for module but in userspace this is solvable with 2 methods
__sleep(), __wakeup(). In case you don't know about them I'll explain. When
PHP wants to serialize an object it tries to execute __sleep() if mehtod
with such name executes. PHP wants to receive an array with names (strings)
of properties that have to be serialized. Probably if there is no __sleep()
all properties are serialized. On the other hand when PHP deserializes an
object it tries to call __wakeup(). __wakeup() is used in case some
initializations are needed on object recreation - in our case (PHP-SOAP)
httpurl is of type resource and has to be created in __wakeup() and not to
be serialized - so __sleep() has to return an array with names where there
is no element "httpurl".
Regards,
Andrey
----- Original Message -----
From: "phpsurf" <ph...@if...>
To: "brad lafountain" <rod...@ya...>;
<php...@li...>
Sent: Friday, May 10, 2002 1:12 PM
Subject: [PHP-SOAP-DEV] bug storing the SoapObject in session
> Hi
>
> I tried something with your 4th example : session
>
> your example shows haow to maintain a session on the server side through
> serveral consecutive calls to method of the SoapObject on the client side,
> but inside the same script.
>
> my idea was to maintain this soap-server session through several calls to
> the soap-client script.
>
> so I simply tried to put the SoapObject (client side) in session.
>
> here is my new session-client-src.php script:
>
> ----------------------------------------------------
> <?
> session_start();
> session_register("session");
>
> if(!isset($session)) {
> echo "create Soap Client\n";
> $session = new
>
SoapObject("http://lab.localhost.com/soap/PhpSoapToolkit/samples/session-ser
> ver-src.php", "urn:Session");
> }
>
> echo "counter:\n";
>
> echo $session->inc() . "\n";
> echo $session->inc() . "\n";
> ?>
> ----------------------------------------------------
>
> The 1st time I call this script, I get the following result :
>
> ----------------------------------------------------
> create Soap Client
> counter:
> 0
> 1
> ----------------------------------------------------
>
>
> But the 2nd time I call this script, I get the following result which is
> fine (the counter is well incremented), except for the warning :)
>
> ----------------------------------------------------
> counter:
> <br />
> <b>Warning</b>: (null)(): supplied argument is not a valid httpurl
resource
> in
<b>c:\webroot\lab\soap\phpsoaptoolkit\samples\session-client-src.php</b>
> on line <b>12</b><br />
> 2
> 3
> ----------------------------------------------------
>
> hope you will find out the bug !
>
>
>
>
____________________________________________________________________________
__
> ifrance.com, l'email gratuit le plus complet de l'Internet !
> vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
> http://www.ifrance.com/_reloc/email.emailif
>
>
>
> _______________________________________________________________
>
> Have big pipes? SourceForge.net is looking for download mirrors. We supply
> the hardware. You get the recognition. Email Us: ban...@so...
> _______________________________________________
> Phpsoaptoolkit-development mailing list
> Php...@li...
> https://lists.sourceforge.net/lists/listinfo/phpsoaptoolkit-development
>
|