Fix: UTF encoding in web services

This commit is contained in:
Laurent Destailleur 2011-03-18 09:54:01 +00:00
parent eaf3e2a3ec
commit 81f58fe8ff
6 changed files with 14 additions and 19 deletions

View File

@ -31,6 +31,7 @@ require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_invoice.php';
$WS_METHOD1 = 'getInvoice';
$WS_METHOD2 = 'getInvoicesForThirdParty';
$ns='http://www.dolibarr.org/ns/';
// Set the WebService URL
@ -39,11 +40,13 @@ $soapclient1 = new nusoap_client($WS_DOL_URL);
if ($soapclient1)
{
$soapclient1->soap_defencoding='UTF-8';
$soapclient1->decodeUTF8(false);
}
$soapclient2 = new nusoap_client($WS_DOL_URL);
if ($soapclient2)
{
$soapclient2->soap_defencoding='UTF-8';
$soapclient2->decodeUTF8(false);
}
// Call the WebService method and store its result in $result.
@ -56,7 +59,7 @@ $authentication=array(
$parameters = array('authentication'=>$authentication,'id'=>1,'ref'=>'');
dol_syslog("Call method ".$WS_METHOD1);
$result1 = $soapclient1->call($WS_METHOD1,$parameters);
$result1 = $soapclient1->call($WS_METHOD1,$parameters,$ns,'');
if (! $result1)
{
print $soapclient1->error_str;
@ -65,7 +68,7 @@ if (! $result1)
$parameters = array('authentication'=>$authentication,'idthirdparty'=>'1');
dol_syslog("Call method ".$WS_METHOD2);
$result2 = $soapclient2->call($WS_METHOD2,$parameters);
$result2 = $soapclient2->call($WS_METHOD2,$parameters,$ns,'');
if (! $result2)
{
print $soapclient2->error_str;

View File

@ -30,6 +30,7 @@ require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_other.php';
$WS_METHOD = 'getVersions';
$ns='http://www.dolibarr.org/ns/';
// Set the WebService URL
@ -38,6 +39,7 @@ $soapclient = new nusoap_client($WS_DOL_URL);
if ($soapclient)
{
$soapclient->soap_defencoding='UTF-8';
$soapclient->decodeUTF8(false);
}
// Call the WebService method and store its result in $result.
@ -49,7 +51,7 @@ $authentication=array(
'entity'=>'');
$parameters = array('authentication'=>$authentication);
dol_syslog("Call method ".$WS_METHOD);
$result = $soapclient->call($WS_METHOD,$parameters);
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
if (! $result)
{
print $soapclient->error_str;

View File

@ -30,6 +30,7 @@ require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP
$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_thirdparty.php';
$WS_METHOD = 'getThirdParty';
$ns='http://www.dolibarr.org/ns/';
// Set the WebService URL
@ -38,6 +39,7 @@ $soapclient = new nusoap_client($WS_DOL_URL);
if ($soapclient)
{
$soapclient->soap_defencoding='UTF-8';
$soapclient->decodeUTF8(false);
}
// Call the WebService method and store its result in $result.
@ -49,7 +51,7 @@ $authentication=array(
'entity'=>'');
$parameters = array('authentication'=>$authentication,'id'=>0,'name'=>'aaa');
dol_syslog("Call method ".$WS_METHOD);
$result = $soapclient->call($WS_METHOD,$parameters);
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
if (! $result)
{
print $soapclient->error_str;

View File

@ -46,6 +46,7 @@ if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
// Create the soap Object
$server = new nusoap_server();
$server->soap_defencoding='UTF-8';
$server->decode_utf8=false;
$ns='http://www.dolibarr.org/ns/';
$server->configureWSDL('WebServicesDolibarrInvoice',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
@ -212,11 +213,6 @@ function getInvoice($authentication,$id,$ref,$ref_ext)
$error++;
$errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
}
if (! $error && ! empty($authentication['entity']) && ! is_numeric($authentication['entity']))
{
$error++;
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter entity must be empty (or a numeric with id of instance if multicompany module is used).";
}
if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
{

View File

@ -46,6 +46,7 @@ if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
// Create the soap Object
$server = new nusoap_server();
$server->soap_defencoding='UTF-8';
$server->decode_utf8=false;
$ns='http://www.dolibarr.org/ns/';
$server->configureWSDL('WebServicesDolibarrOther',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
@ -111,11 +112,6 @@ function getVersions($authentication)
$error++;
$errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
}
if (! $error && ! empty($authentication['entity']) && ! is_numeric($authentication['entity']))
{
$error++;
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter entity must be empty (or a numeric with id of instance if multicompany module is used).";
}
if (! $error)
{

View File

@ -46,6 +46,7 @@ if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
// Create the soap Object
$server = new nusoap_server();
$server->soap_defencoding='UTF-8';
$server->decode_utf8=false;
$ns='http://www.dolibarr.org/ns/';
$server->configureWSDL('WebServicesDolibarrThirdParty',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
@ -153,11 +154,6 @@ function getThirdParty($authentication,$id,$ref,$ref_ext)
$error++;
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
}
if (! $error && ! empty($authentication['entity']) && ! is_numeric($authentication['entity']))
{
$error++;
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter entity must be empty (or a numeric with id of instance if multicompany module is used).";
}
if (! $error)
{