Sessions with PHP5 SOAP Server - How?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

This one's got me stumped.... I want to have a PHP5 SOAP Server with 
persisant sessions.

The wsdl is based on a PHP5 class.

At present, my PHP5 SOAP Client can make one request and everything is 
fine.

But the PHP5 Class seems to be re-initialized each time the SOAP Client 
makes a call to the SOAP Server.

The SOAP Client creates a single SoapClientObject that it uses for each 
call.

Following the suggestion at PHP.net: Session auto start is off and Session 
cookies are on

Cookies are being made.  Each SoapClient Call makes a new cookie with the 
default class values, so I presume their being made by the SoapServer, or 
at least by the script that houses the soap server object.

----------------
following is the relevant part of the SoapServer Script.

// set PHP configuration to allow SoapServer Session Persistance
session_start();

// vars for SoapDiscovery manager. 
$wsdl_file = "QBMS_GW_Service.wsdl";
$class_name = 'QBOpenQBMSGateway';
$class_file = 'class.QBOpenQBMSGateway.php';
$service_name = 'QBMSGateway';
$namespace = "qbopen.com/QBMSGateway/1.0";
$endpoint = 
"https://xproto.qbopen.com:443/QBMSGateway/PROG/LIBQBWS/QBOpenSoapServer.php";;

// Open the class file
require_once $class_file;
 
// set Soap Server options.
$ServerOptions = array ();
$ServerOptions['soap_version'] = SOAP_1_2;
$ServerOptions['trace'] = 1;
$ServerOptions['encoding'] = 'UTF-8';

// It ignites the servant or it unfolds WSDL
if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 
'POST')
{
        // this is a new session
        $server = new SoapServer($wsdl_file, $ServerOptions);
        $server->setClass($class_name); // Note: Classname must be open in 
workspace.
        $server->setPersistence(SOAP_PERSISTENCE_SESSION);
 
        // tell server to work
        $server->handle();

        // save session state
//      $_SESSION["server"] = $server;
}
return;
---------------------------------------------------------------------

Then, the Soap Client has the following relevant code:

$wsdl = "QBMS_GW_Service.wsdl"; 

$ClientOptions = array();
$ClientOptions['soap_version'] = SOAP_1_2;
$ClientOptions['trace'] = 1;
$ClientOptions['encoding'] = 'UTF-8';

try{
    $client = new SoapClient($wsdl, $ClientOptions);
    if (!($client)){
        $error = 'Could not create new SoapClient';
        throw new Exception($error);
    }
    $msgs[] = "SoapClient OK.";
} catch (Exception $e) {
    $msgs[] = 'Caught exception: ' . $e->getMessage() . "<br/>\n";
}
....
$result = $client->ProcessCustomerCreditCardChargeRq(....);
// result is OK.  numerous class variables set, including $msgs

$msgs = $client->GetMsgs();
// returns null, which is default state, although earlier function 
resulted in properties being set.

-----------------------
class has properties such as ErrMsg array.
            $this->ErrMsg["ServerDateTime"] = "ServerDateTime can not be 
null.";

The public GetMsgs() method stringifies the ErrMsg array and returns it.

The class functions properly with a CLI driver program that makes the 
exact same calls as the SOAP Client.

Again, the class seems to be reinitialized with each SOAP Client call, and 
does not behave the same as with the CLI.
-----------------------
My kludgy workaround is to return everything to the SOAP client and let it 
then round-trip it back to the SOAP Server to restore state.

But, that is what I thought SOAP Sessions were supposed to do, so I'm 
confused.

Running PHP 5.0.3 on Windows XP with Apache 2.0.54 (with SSL), but will 
run in production on Debian.

Sincerely,

Bill.McCuistion@QBOpen.com
http://QBOpen.com ... Products, Services & Solutions for Businesses large 
& small
Tel: 281-842-1426 // Cell: 832-217-0771
~~~~~~~~~ (\_~~ (\_~~ (\_~~~~~~~~~~~~~ (\_~~ (\_~~ (\_~~~~~~~~

[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux