PEAR::SOAP Class variable access problem

From: Date: Fri, 03 Feb 2006 22:15:15 +0000
Subject: PEAR::SOAP Class variable access problem
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22784@lists.php.net to get a copy of this message
Hi all, I've a problem with PHP 5.1.1 + PEAR::SOAP 0.9.1 beta + Apache 2.0. I Have the following 2 script that implements a simple web service: The Server Code running on WinXP + PHP5 + Apache 2.x: ---------------------------------------------------- <?php require_once('SOAP/Server.php'); require_once('SOAP/Disco.php'); class pearsoaptest {
    var $__dispatch_map = array();
    var $txt = "I am a test\n";
    function __construct()
    {
        $this->__dispatch_map['AddString'] = array('in' => array('s_in' => 'string'), 'out' => array('s_out' =>
'string'), );
        $this->__dispatch_map['GetString'] = array('in' => array(), 'out' => array('s_out' => 'string'), );
          $this->txt .= "Contructor execution END\n";
    }
    function AddString($s_in)
    {
      $this->txt .= $s_in . "\n";
      return $this->txt;
    }
    function GetString()
    {
      return $this->txt;
    }
} $server = new SOAP_Server(); $webservice = new pearsoaptest(); $server->addObjectMap($webservice,'http://schemas.xmlsoap.org/soap/envelope/'); if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST') {
     $server->service($HTTP_RAW_POST_DATA);
} else {
       $disco = new SOAP_DISCO_Server($server,'pearsoaptest');
       header("Content-type: text/xml");
    if (isset($_SERVER['QUERY_STRING']) && (strcasecmp($_SERVER['QUERY_STRING'],'wsdl') == 0) ) {
        echo $disco->getWSDL();
       } else {
           header("Content-type: text/xml");
           echo $disco->getDISCO();
    }
} exit; ?> and the client script running on WinXP + PHP5 --------------------------------------------- #!/usr/local/bin/php <?php require_once 'SOAP/Client.php'; try {
    $_web_service_url = 'http://localhost/pearsoaptestserver.php?wsdl';
    $wsdl = new SOAP_WSDL($_web_service_url);
    $pearsoaptest = $wsdl->getProxy();
    $params = array("s_in"=>"Adding a Line 2");
    $option = array();
    echo "\n-- Call the web service GET methods:\n";
    $ret = $pearsoaptest->GetString();
    if (PEAR::isError($ret))
    {
      print("Error: " . $ret->getMessage() . "\n");
    } else {
      print ($ret);
    };
    echo "\n-- First Call the web service ADD methods:\n";
    $ret = $pearsoaptest->AddString("Adding a Line 1");
    if (PEAR::isError($ret))
    {
      print("Error: " . $ret->getMessage() . "\n");
    } else {
      print ($ret);
    };
    echo "\n-- Call the web service ADD methods:\n";
    $ret = $pearsoaptest->call("AddString",$params,$option);
    if (PEAR::isError($ret))
    {
      print("Error: " . $ret->getMessage() . "\n");
    } else {
      print ($ret);
    };
    echo "\n-- Call the web service GET methods:\n";
    $ret = $pearsoaptest->GetString();
    if (PEAR::isError($ret))
    {
      print("Error: " . $ret->getMessage() . "\n");
    } else {
      print ($ret);
    };
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
} echo "\n\n"; ?> This is the client execution output: ------------------------------------ D:\Web-Service>php pearsoaptestclient.php -- Call the web service GET methods: I am a test Contructor execution END -- First Call the web service ADD methods: I am a test Contructor execution END Adding a Line 1 -- Call the web service ADD methods: I am a test Contructor execution END Adding a Line 2 -- Call the web service GET methods: I am a test Contructor execution END --------------------------------------------- As you can see the output is not the expected one: I am a test Contructor execution END Adding a Line 1 Adding a Line 2 So I've the idea that the SOAP invocation of a remote class does not permit the access to the class variable to the methods but only to the class constructor (and only the first time it was invoked). Can someone confirm me this thesis or (if is not so) can someone say me what is wrong in the code? Bye and thank you Samuel Zallocco (L'Aquila - ITALY) PS: These are my PEAR installed lib: C:\PHP>pear list INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET: =========================================
PACKAGE        VERSION     STATE
Archive_Tar    1.3.1       stable
Console_Getopt 1.2         stable
DB             1.7.6       stable
HTTP_Request   1.3.0       stable
Mail           1.1.9       stable
Mail_Mime      1.3.1       stable
Net_DIME       0.3         beta
Net_SMTP       1.2.7       stable
Net_Socket     1.0.6       stable
Net_URL        1.0.14      stable
PEAR           1.4.6       stable
PHPUnit        1.3.2       stable
SOAP           0.9.1       beta
UDDI           0.2.0alpha4 alpha
XML_Parser     1.2.7       stable
XML_RPC        1.4.5       stable


« previous php.pear.general (#22784) next »