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

From: Date: Wed, 18 Aug 2021 11:23:27 +0000
Subject: Bug #67533 [Opn]: SoapClient does not honor use=literal
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235936@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67533&edit=1

 ID:                 67533
 Updated by:         cmb@php.net
 Reported by:        cf0hay at gmail dot com
 Summary:            SoapClient does not honor use=literal
 Status:             Open
 Type:               Bug
 Package:            SOAP related
 Operating System:   Linux 64
 PHP Version:        master-Git-2014-06-27 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

This is related to bug #42652.


Previous Comments:
------------------------------------------------------------------------
[2014-06-27 10:15:07] cf0hay at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=67533&edit=1


Thread (2 messages)

« previous php.bugs (#235936) next »