Thursday 15 September 2011

php - How to use a SOAP API with login and session codeigniter -



php - How to use a SOAP API with login and session codeigniter -

i have set of soap apis can perform actions login,logout,keepalive,access other several resources.inorder access other resources,i have pass session id got login api.the session gets time out in 5minutes. confused on how create working.

i using codeigniter project,and have built 1 library set of soap api requests defined in it.

class soap_api { function __construct() { define("uid", "myuser"); define("pwd", "34rf3a45575"); define("api_endpoint", "http://uat-api.testingsoapapi.in/services/smp"); define("product_code", "24"); $resp = $this->keepalivelib(); if($resp['responsecode'] == '0') { define("sessionid",$resp['sessionid']); } } function keepalivelib() { $resp = $this->login(); homecoming $resp; } function 1 { //this function needs sessionid receieved login function } function 2 { //this function needs sessionid receieved login function }

so when ever of functions class accessed,the constructor calls keepalivelib calls login function residing in class , homecoming session id constructor function , set global constant sessionid .so function called using session id made constant.

is standard way of calling apis relay on sessions?the login function called when ever function called , creates different session id.there function keepalive in library can used maintaining session,but instead of using keepalive , im logging each time function in accessed.

is there wrong in flow?can done in other ways?

ok i'm not understanding work?

$resp = $this->keepalivelib(); if($resp['responsecode'] == '0') { $this->sessionid = $resp['sessionid']); } else { // fail gracefully }

$this->sessionid available method in controller.

php codeigniter session soap

No comments:

Post a Comment