|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67533 SoapClient does not honor use=literal
Submitted: 2014-06-27 10:15 UTC Modified: 2021-08-18 11:23 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: cf0hay at gmail dot com Assigned:
Status: Open Package: SOAP related
PHP Version: master-Git-2014-06-27 (Git) OS: Linux 64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cf0hay at gmail dot com
New email:
PHP Version: OS:


 [2014-06-27 10:15 UTC] cf0hay at gmail dot com
SoapClient uses an invalid optimization when the body is requested to be literal by the WSDL. From the specification:

"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:
    $wsdlstring = '<?xml version="1.0"?>
        <xsd:schema targetNamespace="data://,">
          <xsd:element name="callTestRequest">
                <xsd:element maxOccurs="unbounded" name="item">
                      <xsd:element name="data" type="xsd:string"/>
          <xsd:element name="callTestResponse" type="xsd:string"/>

    <wsdl:message name="callTestInput">
        <wsdl:part name="body" element="tns:callTestRequest"/>
    <wsdl:message name="callTestOutput">
        <wsdl:part name="body" element="tns:callTestResponse"/>

    <wsdl:portType name="portType">
        <wsdl:operation name="callTest">
           <wsdl:input message="tns:callTestInput"/>
           <wsdl:output message="tns:callTestOutput"/>

    <wsdl:binding name="binding" type="tns:portType">
        <soap:binding transport=""/>
        <wsdl:operation name="callTest">
               <soap:body use="literal"/>
               <soap:body use="literal"/>

    <wsdl:service name="testService">
        <wsdl:port name="port" binding="tns:binding">
            <soap:address location="data://,"/>


$tempwsdlfile = tempnam(sys_get_temp_dir(),'tempwsdlfile');
    $testService = new SoapClient($tempwsdlfile,['trace' => true]);
    $data = ['data' => 'string'];
    $testService->callTest(['item' => [$data, $data]]);
}catch(SoapFault $e){
echo $testService->__getLastRequest();

Expected result:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" 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="" 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>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-18 11:23 UTC]
This is related to bug #42652.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 17:01:28 2024 UTC