]> granicus.if.org Git - php/commitdiff
Fixed bug #38536 (SOAP returns an array of values instead of an object)
authorDmitry Stogov <dmitry@php.net>
Wed, 8 Nov 2006 10:05:33 +0000 (10:05 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 8 Nov 2006 10:05:33 +0000 (10:05 +0000)
ext/soap/php_encoding.c
ext/soap/tests/bugs/bug38536.phpt [new file with mode: 0755]
ext/soap/tests/bugs/bug38536.wsdl [new file with mode: 0755]

index 84c4aabd39cf9a78afba4ba50ebc70ae3d22868c..712d8bb1ea5615d8ccffda72e463dffda5dc387a 100644 (file)
@@ -1103,13 +1103,14 @@ static void model_to_zval_object(zval *ret, sdlContentModelPtr model, xmlNodePtr
 
                                if (node) {
                                        zval *val;
+                                       xmlNodePtr r_node;
 
-                                       node = check_and_resolve_href(node);
-                                       if (node && node->children && node->children->content) {
-                                               if (model->u.element->fixed && strcmp(model->u.element->fixed, (char*)node->children->content) != 0) {
-                                                       soap_error3(E_ERROR, "Encoding: Element '%s' has fixed value '%s' (value '%s' is not allowed)", model->u.element->name, model->u.element->fixed, node->children->content);
+                                       r_node = check_and_resolve_href(node);
+                                       if (r_node && r_node->children && r_node->children->content) {
+                                               if (model->u.element->fixed && strcmp(model->u.element->fixed, (char*)r_node->children->content) != 0) {
+                                                       soap_error3(E_ERROR, "Encoding: Element '%s' has fixed value '%s' (value '%s' is not allowed)", model->u.element->name, model->u.element->fixed, r_node->children->content);
                                                }
-                                               val = master_to_zval(model->u.element->encode, node);
+                                               val = master_to_zval(model->u.element->encode, r_node);
                                        } else if (model->u.element->fixed) {
                                                xmlNodePtr dummy = xmlNewNode(NULL, BAD_CAST("BOGUS"));
                                                xmlNodeSetContent(dummy, BAD_CAST(model->u.element->fixed));
@@ -1121,7 +1122,7 @@ static void model_to_zval_object(zval *ret, sdlContentModelPtr model, xmlNodePtr
                                                val = master_to_zval(model->u.element->encode, dummy);
                                                xmlFreeNode(dummy);
                                        } else {
-                                               val = master_to_zval(model->u.element->encode, node);
+                                               val = master_to_zval(model->u.element->encode, r_node);
                                        }
                                        if ((node = get_node(node->next, model->u.element->name)) != NULL) {
                                                zval *array;
diff --git a/ext/soap/tests/bugs/bug38536.phpt b/ext/soap/tests/bugs/bug38536.phpt
new file mode 100755 (executable)
index 0000000..1dd84d6
--- /dev/null
@@ -0,0 +1,52 @@
+--TEST--
+Bug #38536 (SOAP returns an array of values instead of an object)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--INI--
+soap.wsdl_cache_enabled=0
+--FILE--
+<?php
+class LocalSoapClient extends SoapClient {
+  function __doRequest($request, $location, $action, $version) {
+    return <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope
+  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
+  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:ns1="http://www.grupos.com.br/ws/enturma/client">
+<SOAP-ENV:Body>
+<getClientInfoFromDomainResponse SOAP-ENC:root="1">
+  <xsd:Result xsi:type="ns1:ClientType">
+    <id xsi:type="xsd:int">2</id>
+    <address href="#i2"/>
+  </xsd:Result>
+</getClientInfoFromDomainResponse>
+<xsd:address id="i2" xsi:type="ns1:ClientAddressType" SOAP-ENC:root="0">
+  <idClient xsi:type="xsd:long">2</idClient>
+  <address href="#i3"/>
+</xsd:address>
+<address xsi:type="xsd:string" id="i3" SOAP-ENC:root="0">Test</address>
+</SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+EOF;
+  }
+}
+
+ini_set("soap.wsdl_cache_enabled", 0);
+$SOAPObject = new LocalSoapClient(dirname(__FILE__).'/bug38536.wsdl');
+print_r($SOAPObject->test());
+?>
+--EXPECT--
+stdClass Object
+(
+    [id] => 2
+    [address] => stdClass Object
+        (
+            [idClient] => 2
+            [address] => Test
+        )
+
+)
diff --git a/ext/soap/tests/bugs/bug38536.wsdl b/ext/soap/tests/bugs/bug38536.wsdl
new file mode 100755 (executable)
index 0000000..0ef3fd4
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
+                                       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+                                       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"                                      
+                                       xmlns:enturma="http://www.grupos.com.br/ws/enturmaServices" 
+                                       xmlns:clientTypes="http://www.grupos.com.br/ws/enturma/client"
+                                       targetNamespace="http://www.grupos.com.br/ws/enturmaServices"
+                                       elementFormDefault="qualified" 
+                                       attributeFormDefault="qualified">
+       <types>
+               <schema  xmlns="http://www.w3.org/2001/XMLSchema" 
+                               xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+                               xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" 
+                               targetNamespace="http://www.grupos.com.br/ws/enturma/client">                           
+                       <complexType name="ClientType">
+                               <sequence>
+                                       <element name="id" type="int"/>
+                                       <element name="address" type="clientTypes:ClientAddressType" minOccurs="0"/>
+                               </sequence>
+                       </complexType>
+                       <complexType name="ClientAddressType">
+                               <sequence>
+                                       <element name="idClient" type="int"/>
+                                       <element name="address" type="string" minOccurs="0"/>
+                               </sequence>
+                       </complexType>
+               </schema>       
+       </types>
+       <message name="testMessage" />  
+       <message name="testResponse">
+               <part name="domain" type="clientTypes:ClientType"/>
+       </message>
+
+       <portType name="SessionImpl">
+               <operation name="test">
+                       <input message="enturma:testMessage" />
+                       <output message="enturma:testResponse" />
+               </operation>
+       </portType>
+       <binding name="SessionBind" type="enturma:SessionImpl">
+               <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+               <operation name="test">
+                       <soap:operation soapAction="test://"/>
+                       <input>
+                               <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="test://"/>
+                       </input>
+                       <output>
+                               <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="test://"/>
+                       </output>
+               </operation>
+       </binding>
+       <service name="Session">
+               <port name="SessionImpl" binding="enturma:SessionBind">
+                       <soap:address location="test://"/>
+               </port>
+       </service>
+</definitions>