From:             wolfgang dot glas at ev-i dot at
Operating system: any
PHP version:      5.0.3
PHP Bug Type:     SOAP related
Bug description:  Returned SOAP-structs are mapped to stdclass instead of 
matching user class.

Description:
------------
The code fragment below shows a PHP SOAP client calling the 
echoStruct() function from the 'base' example of AXIS C++ 
(Apcahe's C++ SOAP-server). This example is supposedly 
included in most SOAP servers. If not, contact me for more 
information. 
 
The struct SOAPStruct is defined in the according wsdl-file 
an the struct correctly passed over to the SOAP server. 
 
When an object of type SOAPStruct is returned by the 
SOAPClient, the returned object is of type 'stdclass' with 
the appropriate attributes. 
 
The returned object can be easily mappedd back to the 
user-defined class, as shown below in the fromStdClass() 
member function. 
 
Nevertheless, it would feasible for most users, if the 
SOAPClient mapped the returned value directly to an Object 
of type 'class SOAPStruct' in the case that the user 
defined a class with a name that matches the struct name in 
the wsdl-file. 
 
IMHO, this feature should become part of the PHP-5.1 
development schedule. 
 
  TIA for considering this suggestion, 
 
    Wolfgang 

Reproduce code:
---------------
class SOAPStruct
{
   public $varString;
   public $varInt;
   public $varFloat;
   function __construct($s= "",$i = 0,$f = 0.0) {
        $this->varString=$s;
        $this->varInt=$i;
        $this->varFloat=$f;
   }
   function fromStdClass($v) {
     foreach($v as $key => $value) {
       $this->$key= $value;
     }
   }
   function printMe() {
        echo
"string=".$this->varString."\nint=".$this->varInt."\nfloat=".$this->varFloat."\n";
    }
}
$s=new SOAPStruct("s_string",43,3.1415926535);
$r=new SOAPStruct;
$client = new SoapClient("http://localhost:8080/axis/base?wsdl";);
echo "********* echoStruct:\n";
echo "**** s:\n"; $s->printMe();
$r->fromStdClass($client->echoStruct($s));
echo "**** r:\n"; $r->printMe();



-- 
Edit bug report at http://bugs.php.net/?id=31869&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31869&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31869&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31869&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31869&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31869&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31869&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31869&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31869&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31869&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31869&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31869&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31869&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31869&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31869&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31869&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31869&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31869&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31869&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31869&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31869&r=mysqlcfg

Reply via email to