Page 1 of 1
[ Zend Framework ] :: SOAP web service with session
Posted: Mon Jan 10, 2011 11:07 pm
by kalpesh.mahida
Is it possible to establish a session between SOAP server and client? If yes, Can anyone guide me how i can do that.
Im using Zend_Soap
Thanks,
Kalpesh Mahida
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Tue Jan 11, 2011 3:10 am
by josh
There is no such construct "soap session". Typically a web service will define it's own way of passing session IDs or API keys around, which will vary from one web service to the next. SOAP is just the protocol and provides no mechanism analogous to HTTP cookies.
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Tue Jan 11, 2011 3:39 am
by kalpesh.mahida
Hi Josh,
Thanks for your reply.
I want to create Statefull Webservices. So, as you said my SOAP server has to create a session and has to return back the session id back to SOAP client and further communication between client and server will be carried out using the session id given by server, right? But how can i do that?
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Tue Jan 11, 2011 4:06 am
by josh
That is a rather open ended question. Are you able to send the string "hello world" and receive it in a client? That is, are you asking how the basics of Zend_Soap component work?
Or are you knowledgeable of SOAP & Zend already, but you need a high level idea on how to establish "state"?
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Tue Jan 11, 2011 5:27 am
by kalpesh.mahida
Yes i know ZF and using Zend_Soap im able to send data from client to server and from server to client. Now my concern is to established a state between client and server and want to store some client specific data into session so that in subsequent webservice call i dont need to prepare those data again and again.
My client and server are running perfect without maintaining state.
again thanks Josh for replying.
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Tue Jan 11, 2011 6:55 am
by josh
Do you understand how regular PHP sessions work? An array of session data on the server is serialized to a string. The file its saved in is named according to a unique session ID. the client hold's a reference (cookie) to the session ID. With each request, the client provides the session ID. the server looks at the session ID to tell which file to unserialize (which file holds the session data for that particular client). A garbage collect routine cleans up the session files after a period of inactivity.
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Tue Jan 11, 2011 7:06 am
by kalpesh.mahida
I know how regular session works. I worked on a Silverlight application where all data where coming to Silverlight via web services and and i found those web services session enabled. how they are doing so? can we do something similar?
or even we forget the .net can we implement the session enabled web services in PHP?
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Tue Jan 11, 2011 7:30 am
by kalpesh.mahida
am i looking something which is not possible?
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Tue Jan 11, 2011 7:28 pm
by josh
Its definitely possible, I just told you how. The same way regular HTTP sessions work. Except instead of cookies your clients will need to track the session ID in another way (ex. database, file, etc.)
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Wed Jan 12, 2011 12:13 am
by kalpesh.mahida
Thanks Josh,
Yes i can make use of file or database to store data between webservice requests ( same thing PHP developer was doing when PHP dint have support for handling session, right? ).
But, After digging a lot google and PHP manual i found something which might help me out.
SoapServer::setPersistence
SoapServer::setPersistence - Sets SoapServer persistence mode
This function allows saving data between requests in a PHP session.
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Wed Jan 12, 2011 1:42 am
by josh
kalpesh.mahida wrote:This function allows saving data between requests in a PHP session.
Actually I guess it seems that most (all?) soap clients support cookies, so you can already use session as normal. That function just automatically saves the current object. However if you are using Zend_Session elsewhere in your project, you should use that instead of this function you've found.
Re: [ Zend Framework ] :: SOAP web service with session
Posted: Wed Jan 12, 2011 2:03 am
by kalpesh.mahida
used Zend_Session but was not working for me.