php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34748 soap: wrong encoding return
Submitted: 2005-10-06 07:11 UTC Modified: 2006-09-13 01:00 UTC
Votes:27
Avg. Score:4.5 ± 0.8
Reproduced:23 of 24 (95.8%)
Same Version:7 (30.4%)
Same OS:10 (43.5%)
From: flobee at gmail dot com Assigned:
Status: No Feedback Package: SOAP related
PHP Version: 5.1.0RC1 OS: xp/*nix
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-10-06 07:11 UTC] flobee at gmail dot com
Description:
------------
request and Response are always set to utf-8 even when server and client are set to ISO-8859-1 :-(
the good: it's handled to be ISO-8859-1 or will throw a SoapFault.



Reproduce code:
---------------
$a =new SoapClient($wsdl, array('encoding'=>'ISO-8859-1');
$b=new SoapServer($wsdl , array('encoding'=>'ISO-8859-1'));

xml-Request : <?xml version="1.0" encoding="UTF-8"?>...
xml-Response: <?xml version="1.0" encoding="UTF-8"?>...


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-06 13:34 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2005-10-06 15:22 UTC] flobee at gmail dot com
[server]
theServerClass {
 function __construct() { }
 function set($in) {
  return array('code'=>'€€€');
 }
}
$server = new SoapServer('a.wsdl',array('encoding'=>'ISO-8859-1'));
$server->setClass('theServerClass');
$server->handle();

[client]
$cli = new SoapClient('a.wsdl', array('encoding'=>'ISO-8859-1','soap_version'=> SOAP_1_2, 'trace'=> 1));
$result = $cli->set('somthing');
print_r($cli->__getLastResponse());

...
xml-Response: <?xml version="1.0" encoding="UTF-8"?> 
but IS ISO-8859-1

set encoding to utf-8 the "€" will throw a SoapFault.
 [2005-10-06 15:30 UTC] tony2001@php.net
And where can I find the a.wsdl ?
 [2005-10-14 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".
 [2006-09-05 18:24 UTC] even at phoniax dot no
I have the same problem in 5.1.4 on a CentOS server.

You can use this WSDL for testing: 
http://webservices.iptelefoni.no/?class=OrderManager&wsdl

The output from __getLastRequest outputs that it requests 
encoding in UTF-8.

Even when I PEAR's Soap Client (which _do_ send the correct 
encoding) the PHP 5.1.4 SoapServer returns the XML in utf8 
encoding.

Both server and client has been set the option for encoding 
to ISO-8859-1.
 [2006-09-13 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".
 [2006-11-07 16:27 UTC] andy at gleep dot org
The utf-8 is hard coded in soap.c so it's not even configurable.

[andy@ddcctdev02 soap]$ grep -n utf *.c
php_encoding.c:763:                     soap_error1(E_ERROR,  "Encoding: string '%s' is not a valid utf-8 string", str);
php_encoding.c:768:             soap_error1(E_ERROR,  "Encoding: string '%s' is not a valid utf-8 string", str);
php_http.c:443:                 smart_str_append_const(&soap_headers,"Content-Type: application/soap+xml; charset=utf-8");
php_http.c:451:                 smart_str_append_const(&soap_headers,"Content-Type: text/xml; charset=utf-8\r\n");
soap.c:1444:                    sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
soap.c:1460:                    sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8"), 1);
soap.c:1859:                    sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
soap.c:1861:                    sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
soap.c:1988:            sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
soap.c:1990:            sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);

This is causing me major problems with 5.1.2 but it's still like that in 5.2.0
 [2006-11-07 16:47 UTC] andy at gleep dot org
Additionally, I'm having problems with the Content-type being set like so:
Content-Type: application/soap+xml; charset=UTF-8; action="urn:LAS_PROVTRANS/GetListOperation"

The SOAP Server that I'm using (Remedy Mid-Tier) doesn't like that string and thinks that the encoding is being set to 'UTF-8; action="urn:LAS_PROVTRANS/GetListOperation" which it doesn't like at all.

Maybe it's a matter of putting quotes around the UTF-8 piece?  I got it to send the UTF-8 in capitals by manually editing the shared library to see if that would fix it.
 [2008-01-23 04:15 UTC] tomisong at gmail dot com
I am also get the same problem that the server request information is flow this:

SOAP-ENV:ServerSOAP-ERROR: Encoding: string '\xb4...' is not a valid utf-8 string

ps:I have used the non-WSDL plz help me thk a lot!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC