summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-11-08 10:05:19 +0000
committerDmitry Stogov <dmitry@php.net>2006-11-08 10:05:19 +0000
commit84b9dcb73f11ea4fd29a9cecc31accf3757b61a6 (patch)
treec3a6f844fae3cd7326f7565acb325ed3d4124809 /ext
parentd6b3b734907aaaf2e0006b1bb4377fc210add5ab (diff)
downloadphp-git-84b9dcb73f11ea4fd29a9cecc31accf3757b61a6.tar.gz
Fixed bug #38536 (SOAP returns an array of values instead of an object)
Diffstat (limited to 'ext')
-rw-r--r--ext/soap/php_encoding.c13
-rwxr-xr-xext/soap/tests/bugs/bug38536.phpt52
-rwxr-xr-xext/soap/tests/bugs/bug38536.wsdl57
3 files changed, 116 insertions, 6 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 8732f29cf3..c18ff0e6f1 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -1137,13 +1137,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));
@@ -1155,7 +1156,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
index 0000000000..1dd84d601e
--- /dev/null
+++ b/ext/soap/tests/bugs/bug38536.phpt
@@ -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
index 0000000000..0ef3fd43cd
--- /dev/null
+++ b/ext/soap/tests/bugs/bug38536.wsdl
@@ -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>