NuSOAP and content type

It is impossible to figure out how to force NuSOAP to use UTF-8 for the content type. he continues to spit out "ISO-8859-1." here are the relevant bits of code I 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 is 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 even went into nusoap.php and changed a couple of lines in which the ISO was hard-coded. What am I missing?

+7
source share
6 answers

Try:

 $soapClient->soap_defencoding = 'UTF-8'; $soapClient->decode_utf8 = false; 

Also make sure you send utf8 encoded data, otherwise this is a bit of a contradiction. (Utf8_encode ()).

+11
source

using SoapClient works great for me.

Here is an example:

 <?php $client = new SoapClient( "http://localhost/app/ws/index.php?ws=data&wsdl", array('encoding' => 'UTF-8',) ); $data = $client->__soapCall("data.getData", array(1)); ?> 

Tested with PHP 5.3.3.

+1
source

Edit

 $soapclient->defencoding='utf-8'; 

to

 $soapclient->soap_defencoding='utf-8'; 
+1
source

It seems that in NuSOAP, the HTTP content type is set in two files:

 class.soap_server.php nusoap.php 

First find the lines in each file:

 header("Content-Type: text/xml; charset=ISO-8859-1\r\n"); 

and replace them with

 header("Content-Type: text/xml; charset=UTF-8\r\n"); 

It will solve your problem with HTTP headers. But I'm not sure that this will solve any encoding problem, since I am struggling with the problem of encoding UTF-8 in NuSOAP, this is not only related to HTTP headers.

+1
source

Here is what I ended up doing when I ran into this problem (I pulled my hair out a couple of days later):

I went through the NuSOAP files and found a variable: $soap_defencoding , which defaults to ISO-8859-1 . However, the line below shows the comment version, which defaults to UTF-8 .

There are two places that I found: nusoap_base.php and nusoap.php . I found that my problem disappeared when I changed it (reverse comment on two lines).

Problem: client complains that response encoding is ISO-8859-1
Decision. Change the following lines in the NuSOAP files nusoap_base.php and nusoap.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 desktop application "Client β†’ VB.NET 3.5"

0
source

Double checking the actual file is utf-8 encoded. Sometimes the problem is the actual file, and its encoding usually happens with the Linux server.

Try changing the entire nusoap library and controller and browse files.

Change the sample ANSI file to utf-8 or utf-8 without specification.

thanks.

0
source

All Articles