Can't figure out how to make NuSOAP use UTF-8 for a content type. it keeps spitting out "ISO-8859-1". here's the relevant code bits that I've tried:
$soapclient=new soapclient($url1,'wsdl');
$soapclient->http_encoding='utf-8';
$soapclient->defencoding='utf-8';
if($soapclient->fault){
$retdata=$soapclient->fault;
}else{
if($soapclient->getError()){
$retdata=$soapclient->getError();
}else{
$params=array($xmldata);
$retdata=$soapclient->call($doit,$params,$url1,$url2);
}
}
here's the request:
POST xxxxxxxxxxxx HTTP/1.0
Host: xxxxxxxxxxxxx
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "xxxxxxxxxxxxxxxxx"
Content-Length: 1629
I've even gone into nusoap.php and changed a couple of lines that had the ISO hard-coded in. What am I missing?
Change
to
Try:
Also make sure you're sending utf8 encoded data, otherwise it's a bit of a contradiction. (utf8_encode()).
It seems in NuSOAP, HTTP content type is being set in two files :
First find lines in each file :
and replace them with
It will solve your problem with HTTP headers. But I am not sure that this will solve any encoding problem since I have been struggling with UTF-8 encoding problem in NuSOAP it is not only because of HTTP Headers.
using SoapClient works fine for me.
Here is an example:
Tested with PHP 5.3.3.
Double check the actual file is it is under utf-8 encoding. Sometimes the problem is the actual file and its encoding usually happens with Linux server.
Try changing the whole nusoap library and the controller and view files.
Change the file example ANSI to utf-8 or utf-8 without BOM.
thanks.
Here is what I ended up doing when I was faced with this problem (after a couple of days of pulling my hair out):
Went digging through the NuSOAP files and found the variable:
$soap_defencoding
which defaults toISO-8859-1
. However, on the line right below is a comment out version of the declaration that defaults toUTF-8
.There are two places that I found this:
nusoap_base.php
andnusoap.php
. I found my problem went away when I had both changed over (inverse the commenting on the two lines).Problem: Client complains that the response encoding is
ISO-8859-1
Solution: Change the following lines in the NuSOAP files
nusoap_base.php
andnusoap.php
:from:
var $soap_defencoding = 'ISO-8859-1';
//var $soap_defencoding = 'UTF-8';
to:
//var $soap_defencoding = 'ISO-8859-1';
var $soap_defencoding = 'UTF-8';
For reference my Client -> VB.NET 3.5 desktop application