Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuSOAP and content type

Tags:

php

nusoap

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?

like image 689
Bill Avatar asked Mar 15 '11 20:03

Bill


2 Answers

Try:

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

Also make sure you're sending utf8 encoded data, otherwise it's a bit of a contradiction. (utf8_encode()).

like image 187
vicTROLLA Avatar answered Oct 21 '22 07:10

vicTROLLA


using SoapClient works fine 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.

like image 20
Jorge Olivares Avatar answered Oct 21 '22 08:10

Jorge Olivares