Bug #67533 [NEW]: SoapClient does not honor use=literal

From: Date: Fri, 27 Jun 2014 10:15:09 +0000
Subject: Bug #67533 [NEW]: SoapClient does not honor use=literal
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186360@lists.php.net to get a copy of this message
From: cf0hay at gmail dot com Operating system: Linux 64 PHP version: master-Git-2014-06-27 (Git) Package: SOAP related Bug Type: Bug Bug description:SoapClient does not honor use=literal Description: ------------ SoapClient uses an invalid optimization when the body is requested to be literal by the WSDL. From the specification: http://www.w3.org/TR/wsdl#_soap:body "If use is literal, then each part references a concrete schema definition using either the element or type attribute." "<ns1:callTestRequest><item id="ref1"><data>string</data></item><item href="#ref1"/></ns1:callTestRequest>" is not valid by the <schema/> defined by the wsdl, but it should be as it is requested to be literal. Test script: --------------- #!/usr/bin/php <?php $wsdlstring = '<?xml version="1.0"?> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="data://," targetNamespace="data://," > <wsdl:types> <xsd:schema targetNamespace="data://,"> <xsd:element name="callTestRequest"> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="unbounded" name="item"> <xsd:complexType> <xsd:sequence> <xsd:element name="data" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="callTestResponse" type="xsd:string"/> </xsd:schema> </wsdl:types> <wsdl:message name="callTestInput"> <wsdl:part name="body" element="tns:callTestRequest"/> </wsdl:message> <wsdl:message name="callTestOutput"> <wsdl:part name="body" element="tns:callTestResponse"/> </wsdl:message> <wsdl:portType name="portType"> <wsdl:operation name="callTest"> <wsdl:input message="tns:callTestInput"/> <wsdl:output message="tns:callTestOutput"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="binding" type="tns:portType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="callTest"> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="testService"> <wsdl:port name="port" binding="tns:binding"> <soap:address location="data://,"/> </wsdl:port> </wsdl:service> </wsdl:definitions>'; $tempwsdlfile = tempnam(sys_get_temp_dir(),'tempwsdlfile'); file_put_contents($tempwsdlfile,$wsdlstring); try{ $testService = new SoapClient($tempwsdlfile,['trace' => true]); $data = ['data' => 'string']; $testService->callTest(['item' => [$data, $data]]); }catch(SoapFault $e){ } echo $testService->__getLastRequest(); unlink($tempwsdlfile); Expected result: ---------------- <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="data://,"><SOAP-ENV:Body><ns1:callTestRequest><item><data>string</data></item><item><data>string</data></item></ns1:callTestRequest></SOAP-ENV:Body></SOAP-ENV:Envelope> Actual result: -------------- <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="data://,"><SOAP-ENV:Body><ns1:callTestRequest><item id="ref1"><data>string</data></item><item href="#ref1"/></ns1:callTestRequest></SOAP-ENV:Body></SOAP-ENV:Envelope> -- Edit bug report at https://bugs.php.net/bug.php?id=67533&edit=1 --

« previous php.bugs (#186360) next »