From: heitor dot m at gmail dot com Operating system: Linux RedHat Enterprise V4 PHP version: 5.2.3 PHP Bug Type: SOAP related Bug description: Object Type mismatch using classmap in WSDL mode
Description: ------------ tryning to get the object type that i was specified in classmap option. i ever get a object of the type stdClass. I'm expecting to get in this case a instance of the Class PHPObject previusly declared by me. I already search for related bug reports and just has found this: http://bugs.php.net/bug.php?id=42157 thats already closed. Reproduce code: --------------- SERVER(teste_ser.php): <?php ini_set("soap.wsdl_cache_enabled", "0"); class PHPObject { public $prop1; public $prop2; public $propc; public function __construct($a, $b, $c) { $this->prop1 = $a; $this->prop2 = $b; $this->propc = $c; } } function send($arg_obj) { $obj = new PHPObject("SERVER_1", "SERVER_2", "SERVER_3"); return $obj; } $classmap = array('WSDLObject' => 'PHPObject'); $server = new SoapServer("teste.wsdl", array('classmap' => $classmap)); $server->addFunction(array("send")); $server->handle(); ?> ============================================= CLIENT(teste_cli.php): <?php ini_set("soap.wsdl_cache_enabled", "0"); class PHPObject { public $prop1; public $prop2; public $propc; public function __construct($a, $b, $c) { $this->prop1 = $a; $this->prop2 = $b; $this->propc = $c; } } try { $classmap = array('WSDLObject' => 'PHPObject'); $client = new SoapClient("teste.wsdl", array("classmap" => $classmap, 'trace' => 1)); $arg_obj = new PHPObject("ARG_1", "ARG_2", "ARG_3"); $res = $client->send($arg_obj); echo "<hr>RESPONSE FROM SERVER<hr><pre>"; var_dump($res); echo "</pre><hr>"; echo "<hr>SOAP RESPONSE<hr><pre>"; echo htmlspecialchars(str_replace("><", ">\n<", $client->__getLastResponse())); echo "</pre><hr>"; } catch (SoapFault $sf) { echo "<hr><pre>"; print_r("(" . $sf->faultcode . ") " . $sf->faultstring); echo "</pre><hr>"; } catch (Exception $e) { echo "<hr><pre>"; print_r($e); echo "</pre><hr>"; } ?> ====================================================== WSDL(teste.wsdl): <?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.sit.com.br/wsdl" xmlns:soap-env="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://www.w3.org/2003/06/wsdl" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" targetNamespace="http://www.sit.com.br/wsdl"> <!-- ### TYPES ### --> <types> <xsd:complexType name="WSDLObject"> <xsd:sequence> <xsd:element minOccurs="1" name="param1" type="xsd:string"/> <xsd:element minOccurs="1" name="param2" type="xsd:string"/> <xsd:element minOccurs="1" name="param3" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </types> <!-- ### [END] TYPES [END] ### --> <!-- ### MESSAGES ### --> <message name="sendRequest"> <part name="arg1" type="tns:WSDLObject"/> </message> <message name="sendResponse"> <part name="result" type="tns:WSDLObject"/> </message> <!-- ### [END] MESSAGES [END] ### --> <!-- ### PORTTYPE ### --> <portType name="Type_ports"> <operation name="send"> <input message="tns:sendRequest"/> <output message="tns:sendResponse"/> </operation> </portType> <!-- ### [END] PORTTYPE [END] ### --> <!-- ### BINDING ### --> <binding name="Type_bind" type="tns:Type_ports"> <soap-env:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="send"> <soap-env:operation soapAction="Type_ports#send"/> <input name="sendRequest"> <soap-env:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Types" use="literal" /> </input> <output name="sendResponse"> <soap-env:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:Types" use="literal" /> </output> </operation> </binding> <!-- ### [END] BINDING [END] ### --> <service name="Type_service"> <documentation>Web-Services para operaes matematicas</documentation> <port binding="tns:Type_bind" name="Type_port_bind"> <soap-env:address location="http://10.11.40.177/developers/heitor/ws/teste/teste_ser.php"/> </port> </service> </definitions> Expected result: ---------------- RESPONSE FROM SERVER object(PHPObject)[3] public 'prop1' => string 'SERVER_1' (length=8) public 'prop2' => string 'SERVER_2' (length=8) public 'propc' => string 'SERVER_3' (length=8) [methods list] SOAP RESPONSE <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <result xsi:type="PHPObject"> <prop1>SERVER_1</prop1> <prop2>SERVER_2</prop2> <propc>SERVER_3</propc> </result> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Actual result: -------------- RESPONSE FROM SERVER object(stdClass)[3] public 'prop1' => string 'SERVER_1' (length=8) public 'prop2' => string 'SERVER_2' (length=8) public 'propc' => string 'SERVER_3' (length=8) SOAP RESPONSE <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <result xsi:type="PHPObject"> <prop1>SERVER_1</prop1> <prop2>SERVER_2</prop2> <propc>SERVER_3</propc> </result> </SOAP-ENV:Body> </SOAP-ENV:Envelope> -- Edit bug report at http://bugs.php.net/?id=42184&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42184&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42184&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42184&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42184&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42184&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42184&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42184&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42184&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42184&r=support Expected behavior: http://bugs.php.net/fix.php?id=42184&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42184&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42184&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42184&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42184&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42184&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42184&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42184&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42184&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42184&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42184&r=mysqlcfg