From:             fjas at free dot fr
Operating system: Windows XP
PHP version:      5.2.6
PHP Bug Type:     SOAP related
Bug description:  Performance hit with utf8 accented characters in rpc/encoded 
style

Description:
------------
PHP5 SOAPClient is very slow to decode xsd:string return values containing
utf8 accented characters sent by a Perl SOAP::Lite server.

Strangely enough, I could not reproduce the problem using a PHP5
SOAPServer, so I first suspected the SOAP::Lite server to be slow to
respond, for some reason.

But it turned out that a nuSOAP client got the answer instantly, and so
did a SOAP::Lite client (with the same configuration, in terms of machines,
network, load...)

This is the envelope sent back by SOAP::Lite:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";><SOAP-ENV:Body><namesp1:getImageResponse
xmlns:namesp1="http://www.curie.fr/hermes/";><s-gensym3
xsi:type="xsd:string">Séverine est
là.</s-gensym3></namesp1:getImageResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
I don't see anything wrong in it, compared to what a PHP5 SOAPServer would
send.
It took 5 or 6 seconds for a PHP5 SOAPClient to get it.
It took 1 second for a nuSOAP or a SOAPLite client to do the same job.

More annoying, if the return value is a bit larger (say, 400 characters),
the difference of execution time between a PHP5 SoapClient and a nuSOAP
client can become very important: PHP5 SOAPClient does the job in more than
30 seconds (I had to increase the default set_time_limit), while nuSOAP or
SOAP::Lite clients reply in 2 or 3 seconds.

Additional remarks:
1. If you replace the accented characters by unaccented ones, the
performance hit disappears immediately.
2. If the server sends the same message in base64Binary characters, the
performance hit disappears too (that's the workaround I used).
3. The presence of just one accented character is enough to suddenly
increase the execution time significantly.

----
My PHP Configure (where the SOAPClient is executed):
"--enable-snapshot-build" "--with-gd=shared"
"--with-extra-includes=C:\Program Files (x86)\Microsoft
SDK\Include;C:\PROGRA~2\MICROS~2\VC98\ATL\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\MFC\INCLUDE"
"--with-extra-libs=C:\Program Files (x86)\Microsoft
SDK\Lib;C:\PROGRA~2\MICROS~2\VC98\LIB;C:\PROGRA~2\MICROS~2\VC98\MFC\LIB"

Apache Version : Apache/2.2.8 (Win32) PHP/5.2.6  


Reproduce code:
---------------
Expose that SOAP::Lite server:

package hermes;

use strict;
use Encode;

sub getImage
{
        my $str = 'Séverine est là.';
        my $str = encode("utf8", $str);
        return SOAP::Data->type(string => $str);
}
1;

Request it with:
$client = new SoapClient('ws.wsdl', array('trace'=>1));
$r = $client->getImage();
exit($client->__getLastResponse());

--
You can use, for "ws.wsdl":

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions name="hermes"
targetNamespace="http://www.foo.com/hermes/";
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
        xmlns:tns="http://www.foo.com/hermes/";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
        xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
        <wsdl:types />
        <wsdl:message name="getImageRequest"></wsdl:message>
        <wsdl:message name="getImageResponse">
                <wsdl:part name="return" type="xsd:string"></wsdl:part>
        </wsdl:message>
        <wsdl:portType name="hermes">
                <wsdl:operation name="getImage">
                        <wsdl:input message="tns:getImageRequest"></wsdl:input>
                        <wsdl:output 
message="tns:getImageResponse"></wsdl:output>
                </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="hermesSOAP" type="tns:hermes">
                <soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"; />
                <wsdl:operation name="getImage">
                        <soap:operation 
soapAction="http://www.foo.com/hermes/getImage"; />
                        <wsdl:input>
                                <soap:body use="encoded" 
namespace="http://www.foo.com/hermes/";
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; />
                        </wsdl:input>
                        <wsdl:output>
                                <soap:body use="encoded"
namespace="http://www.foo.com/hermes/";          
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
/>
                        </wsdl:output>
                </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="hermes_bioinfo">
                <wsdl:port binding="tns:hermesSOAP" name="hermesSOAP">
                        <soap:address 
location="http://host/your_dispatcher.cgi"; />
                </wsdl:port>
        </wsdl:service>
</wsdl:definitions>



Expected result:
----------------
A response in a reasonable time.

Actual result:
--------------
A response with a large delay

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

Reply via email to