]> granicus.if.org Git - php/commitdiff
Fixed bug #41004 (minOccurs="0" and null class member variable)
authorDmitry Stogov <dmitry@php.net>
Wed, 2 May 2007 09:38:22 +0000 (09:38 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 2 May 2007 09:38:22 +0000 (09:38 +0000)
ext/soap/php_encoding.c
ext/soap/tests/bugs/bug41004.phpt [new file with mode: 0755]
ext/soap/tests/bugs/bug41004.wsdl [new file with mode: 0755]

index 7386ccca21df0bd7298ff73e5aae4be2cf77ddf3..9f5d1d1585dae56fddd07bc00226447f10d29318 100644 (file)
@@ -1563,6 +1563,8 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *
                                                property = xmlNewNode(NULL, BAD_CAST("BOGUS"));
                                                xmlAddChild(node, property);
                                                set_xsi_nil(property);
+                                       } else if (Z_TYPE_P(data) == IS_NULL && model->min_occurs == 0) {
+                                               return 1;
                                        } else {
                                                property = master_to_xml(enc, data, style, node);
                                                if (property->children && property->children->content &&
diff --git a/ext/soap/tests/bugs/bug41004.phpt b/ext/soap/tests/bugs/bug41004.phpt
new file mode 100755 (executable)
index 0000000..5f359d9
--- /dev/null
@@ -0,0 +1,36 @@
+--TEST--
+Bug #41004 minOccurs="0" and null class member variable 
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ini_set('soap.wsdl_cache_enabled', false);
+
+class EchoBean{
+       public $mandatoryElement;
+       public $optionalElement;
+       
+}
+
+class EchoRequest{
+       public $in;
+}
+
+class EchoResponse{
+       public $out;
+}
+
+$wsdl = dirname(__FILE__)."/bug41004.wsdl";
+$classmap = array('EchoBean'=>'EchoBean','echo'=>'EchoRequest','echoResponse'=>'EchoResponse');
+$client = new SoapClient($wsdl, array('location'=>'test://',"classmap" => $classmap, 'exceptions'=>0, 'trace'=>1));
+$echo=new EchoRequest();
+$in=new EchoBean();
+$in->mandatoryElement="REV";
+$in->optionalElement=NULL;
+$echo->in=$in;
+$client->echo($echo);
+echo $client->__getLastRequest();
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Formation"><SOAP-ENV:Body><ns1:echo><in><mandatoryElement>REV</mandatoryElement></in></ns1:echo></SOAP-ENV:Body></SOAP-ENV:Envelope>
diff --git a/ext/soap/tests/bugs/bug41004.wsdl b/ext/soap/tests/bugs/bug41004.wsdl
new file mode 100755 (executable)
index 0000000..d683e5d
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"\r
+       xmlns:tns="urn:Formation" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"\r
+       xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Formation"\r
+       targetNamespace="urn:Formation">\r
+       <wsdl:types>\r
+               <xsd:schema targetNamespace="urn:Formation">\r
+                       <xsd:element name="echo">\r
+                               <xsd:complexType>\r
+                                       <xsd:sequence>\r                                         <xsd:element name="in" type="tns:EchoBean"></xsd:element>
+                                       </xsd:sequence>\r
+                               </xsd:complexType>\r
+                       </xsd:element>
+                       <xsd:element name="echoResponse">
+                               <xsd:complexType>
+                                       <xsd:sequence>\r
+                                               <xsd:element name="out" type="tns:EchoBean"></xsd:element>
+                                       </xsd:sequence>\r
+                               </xsd:complexType>\r
+                       </xsd:element>
+                       <xsd:simpleType name="Product1Type">\r
+                               <xsd:restriction base="xsd:string">\r
+                                       <xsd:enumeration value="REV"></xsd:enumeration>\r
+                                       <xsd:enumeration value="CLA"></xsd:enumeration>\r
+                               </xsd:restriction>\r
+                       </xsd:simpleType>\r
+\r
+                       <xsd:complexType name="EchoBean">
+                               <xsd:sequence>
+                                       <xsd:element name="mandatoryElement"\r
+                                               type="tns:Product1Type">
+                                       </xsd:element>\r
+                                       <xsd:element name="optionalElement"\r
+                                               type="tns:Product1Type" maxOccurs="1" minOccurs="0">\r
+                                       </xsd:element>
+                               </xsd:sequence>\r
+                       </xsd:complexType>
+               </xsd:schema>\r
+       </wsdl:types>\r
+       <wsdl:message name="echoRequest">\r
+               <wsdl:part name="parameters" element="tns:echo"></wsdl:part>\r
+       </wsdl:message>
+       <wsdl:message name="echoResponse">
+               <wsdl:part name="parameters" element="tns:echoResponse"></wsdl:part>\r
+       </wsdl:message>
+       <wsdl:portType name="Formation">\r
+               <wsdl:operation name="echo">\r
+                       <wsdl:input message="tns:echoRequest"></wsdl:input>
+                       <wsdl:output message="tns:echoResponse"></wsdl:output>\r
+               </wsdl:operation>
+       </wsdl:portType>\r
+       <wsdl:binding name="FormationServiceV1" type="tns:Formation">\r          <soap:binding style="document"\r                 transport="http://schemas.xmlsoap.org/soap/http" />\r            <wsdl:operation name="echo">\r
+                       <soap:operation soapAction="urn:Formation/echo" />
+                       <wsdl:input>
+                               <soap:body use="literal" />\r
+                       </wsdl:input>
+                       <wsdl:output>
+                               <soap:body use="literal" />\r
+                       </wsdl:output>\r
+               </wsdl:operation>
+       </wsdl:binding>\r
+       <wsdl:service name="Formation">\r
+               <wsdl:port binding="tns:FormationServiceV1"\r
+                       name="FormationSOAP">\r
+                       <soap:address\r
+                               location="http://localhost:8080/webapp/services/FormationServiceV1" />\r
+               </wsdl:port>\r
+       </wsdl:service>\r
+</wsdl:definitions>\r