php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45934 Performance hit with utf8 accented characters in rpc/encoded style
Submitted: 2008-08-27 14:33 UTC Modified: 2009-05-08 01:00 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: fjas at free dot fr Assigned:
Status: No Feedback Package: SOAP related
PHP Version: 5.2.6 OS: Windows XP
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-08-27 14:33 UTC] fjas at free dot fr
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-30 11:05 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-08 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 09:01:28 2024 UTC