From:             afalak at poczta dot onet dot pl
Operating system: Windows 2000
PHP version:      5CVS-2006-07-10 (CVS)
PHP Bug Type:     SOAP related
Bug description:  Wrong interpretation of boolean parameters

Description:
------------
This error is related to parameters typed as boolean in WSDL. Passing 1 or
TRUE works fine, but '1' (string) or 2 (integer) is interpreted as FALSE.
Why aren't such parameters interpreted like elsewhere in PHP (in if()
i.e.)?

Note: This error pertains to both SoapClient and SoapServer, although the
example is for client only.

Reproduce code:
---------------
[client]
<?php
$client = new SoapClient('a.wsdl');
$boolA = 1;
$boolB = '1';
$res = $client->Test(array('boolA'=>$boolA, 'boolB'=>$boolB));
?>

[server]
<?php
function Test($param) {
        file_put_contents('test.txt',
                ($param->boolA ? 'true' : 'false')."\n".
                ($param->boolB ? 'true' : 'false'));
        return 1;
}
$server = new SoapServer('a.wsdl');
$server->addFunction('Test');
$server->handle();
?>

[a.wsdl]
<?xml version="1.0" encoding="UTF-8"?>
<definitions
                xmlns:http="http://schemas.xmlsoap.org/wsdl/http/";
                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
                xmlns:s="http://www.w3.org/2001/XMLSchema";
                xmlns:s0="http://test.pl";
                targetNamespace="http://test.pl";
                xmlns="http://schemas.xmlsoap.org/wsdl/";
>
        <types>
                <s:schema elementFormDefault="qualified"
targetNamespace="http://test.pl";>
                        <s:complexType name="Test">
                                <s:attribute use="required" name="boolA" 
type="s:boolean"/>
                                <s:attribute use="required" name="boolB" 
type="s:boolean"/>
                        </s:complexType>
                        <s:element type="s0:Test" name="Test"/>
                        <s:element type="s:int" name="Ret"/>
                </s:schema>
        </types>

        <message name="TestSoapIn">
                <part name="parameters" element="s0:Test"/>
        </message>
        <message name="TestSoapOut">
                <part name="parameters" element="s0:Ret"/>
        </message>
        <portType name="TestSoap">
                <operation name="Test">
                        <input message="s0:TestSoapIn"/>
                        <output message="s0:TestSoapOut"/>
                </operation>
        </portType>
        <binding name="TestSoap" type="s0:TestSoap">
                <soap:binding transport="http://schemas.xmlsoap.org/soap/http";
style="document"/>
                <operation name="Test">
                        <soap:operation soapAction="http:/Test/Test" 
style="document"/>
                        <input>
                                <soap:body use="literal"/>
                        </input>
                        <output>
                                <soap:body use="literal"/>
                        </output>
                </operation>
        </binding>
        <service name="Test">
                <port name="TestSoapPort" binding="s0:TestSoap">
                        <soap:address location="http://localhost/server.php"/>
                </port>
        </service>
</definitions>


Expected result:
----------------
File test.txt should contain:
true
true


Actual result:
--------------
File test.txt contains:
true
false


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

Reply via email to