php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cf0hay at gmail dot com
New email:
PHP Version: OS:

 

 [2014-06-27 10:15 UTC] 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>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-18 11:23 UTC] cmb@php.net
This is related to bug #42652.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC