[ Zend Framework ] :: SOAP web service with session

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

[ Zend Framework ] :: SOAP web service with session

Post 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
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: [ Zend Framework ] :: SOAP web service with session

Post 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.
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: [ Zend Framework ] :: SOAP web service with session

Post 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?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: [ Zend Framework ] :: SOAP web service with session

Post 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"?
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: [ Zend Framework ] :: SOAP web service with session

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: [ Zend Framework ] :: SOAP web service with session

Post 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.
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: [ Zend Framework ] :: SOAP web service with session

Post 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?
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: [ Zend Framework ] :: SOAP web service with session

Post by kalpesh.mahida »

am i looking something which is not possible?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: [ Zend Framework ] :: SOAP web service with session

Post 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.)
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: [ Zend Framework ] :: SOAP web service with session

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: [ Zend Framework ] :: SOAP web service with session

Post 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.
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: [ Zend Framework ] :: SOAP web service with session

Post by kalpesh.mahida »

used Zend_Session but was not working for me.
Post Reply