#36908 [NEW]: wsdl default value overrides value in soap request

From: Date: Wed, 29 Mar 2006 10:39:52 +0000
Subject: #36908 [NEW]: wsdl default value overrides value in soap request
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95052@lists.php.net to get a copy of this message
From:             amatunin at iponweb dot net
Operating system: Linux Debian testing
PHP version:      5CVS-2006-03-29 (snap)
PHP Bug Type:     SOAP related
Bug description:  wsdl default value overrides value in soap request

Description:
------------
PHP SOAP server may parse SOAP request from client incorrectly if some
variable in wsdl has a default value. I.e. value in the request gets
ignored and the default value from WSDL is being used. Apparently the
problem is being triggered by certain SOAP clients which generate SOAP
packets with multiple references (for example Java's Asix does that). If
WSDL doesn't define default values then PHP SOAP server parses exactly the
same SOAP request correctly.

Reproduce code:
---------------
----test-server.php-----
<?php
class PublisherService {

  function add ($publisher) {
    return print_r ($publisher, true);
  }
}
$input =
'<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <ns1:add xmlns:ns1="urn:PublisherService"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <publisher href="#id0"/>
    </ns1:add>
    <multiRef xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns3="http://soap.dev/soap/types"
id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns3:publisher">
      <region_id href="#id5"/>
    </multiRef>
    <multiRef xmlns:ns5="http://soap.dev/soap/types"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
id="id5"
soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="xsd:long">9</multiRef>
  </soapenv:Body>
</soapenv:Envelope>';
ini_set('soap.wsdl_cache_enabled', false);
$server = new SoapServer("wsdl.xml");
$server->setClass("PublisherService");
$server->handle($input);
?>

-------wsdl.xml--------
<?xml version="1.0"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:api="http://soap.dev/soap/PublisherService"
xmlns:types="http://soap.dev/soap/types"
targetNamespace="http://soap.dev/soap/PublisherService">
  <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:types="http://soap.dev/soap/types"
targetNamespace="http://soap.dev/soap/types">
      <xsd:complexType name="publisher">
        <xsd:all>
          <xsd:element name="region_id" type="xsd:long"
default="52"/>
        </xsd:all>
      </xsd:complexType>
    </xsd:schema> 
  </wsdl:types>
  <wsdl:message name="addInput">
    <wsdl:part name="publisher" type="types:publisher"/>
  </wsdl:message>
  <wsdl:message name="addOutput">
    <wsdl:part name="out" type="xsd:string"/>
  </wsdl:message>
  <wsdl:portType name="PublisherServicePortType">
    <wsdl:operation name="add">
      <wsdl:input message="api:addInput"/>
      <wsdl:output message="api:addOutput"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="PublisherServiceBinding"
type="api:PublisherServicePortType">
    <soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="add">
      <soap:operation soapAction="urn:PublisherService#add" style="rpc"/>
      <wsdl:input>
        <soap:body use="encoded" namespace="urn:PublisherService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="encoded" namespace="urn:PublisherService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="PublisherService">
    <wsdl:port name="PublisherServicePort"
binding="api:PublisherServiceBinding">
      <soap:address location="http://soap.dev/soap//publisher_test.php"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:PublisherService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:addResponse><out
xsi:type="xsd:string">stdClass Object
(
    [region_id] =&gt; 9
)
</out></ns1:addResponse></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="urn:PublisherService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:addResponse><out
xsi:type="xsd:string">stdClass Object
(
    [region_id] =&gt; 52
)
</out></ns1:addResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

-- 
Edit bug report at http://bugs.php.net/?id=36908&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36908&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36908&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36908&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36908&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=36908&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36908&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36908&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36908&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36908&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36908&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=36908&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=36908&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36908&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36908&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36908&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36908&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36908&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36908&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36908&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36908&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#95052) next »