Skip to content

Commit

Permalink
Fix: UTF encoding in web services
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 18, 2011
1 parent eaf3e2a commit 81f58fe
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
7 changes: 5 additions & 2 deletions htdocs/webservices/demo_wsclient_invoice.php
Expand Up @@ -31,6 +31,7 @@
$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
Expand All @@ -39,11 +40,13 @@
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.
Expand All @@ -56,7 +59,7 @@

$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;
Expand All @@ -65,7 +68,7 @@

$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;
Expand Down
4 changes: 3 additions & 1 deletion htdocs/webservices/demo_wsclient_other.php
Expand Up @@ -30,6 +30,7 @@

$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_other.php';
$WS_METHOD = 'getVersions';
$ns='http://www.dolibarr.org/ns/';


// Set the WebService URL
Expand All @@ -38,6 +39,7 @@
if ($soapclient)
{
$soapclient->soap_defencoding='UTF-8';
$soapclient->decodeUTF8(false);
}

// Call the WebService method and store its result in $result.
Expand All @@ -49,7 +51,7 @@
'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;
Expand Down
4 changes: 3 additions & 1 deletion htdocs/webservices/demo_wsclient_thirdparty.php
Expand Up @@ -30,6 +30,7 @@

$WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_thirdparty.php';
$WS_METHOD = 'getThirdParty';
$ns='http://www.dolibarr.org/ns/';


// Set the WebService URL
Expand All @@ -38,6 +39,7 @@
if ($soapclient)
{
$soapclient->soap_defencoding='UTF-8';
$soapclient->decodeUTF8(false);
}

// Call the WebService method and store its result in $result.
Expand All @@ -49,7 +51,7 @@
'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;
Expand Down
6 changes: 1 addition & 5 deletions htdocs/webservices/server_invoice.php
Expand Up @@ -46,6 +46,7 @@
// 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;
Expand Down Expand Up @@ -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)))
{
Expand Down
6 changes: 1 addition & 5 deletions htdocs/webservices/server_other.php
Expand Up @@ -46,6 +46,7 @@
// 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;
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 1 addition & 5 deletions htdocs/webservices/server_thirdparty.php
Expand Up @@ -46,6 +46,7 @@
// 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;
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 81f58fe

Please sign in to comment.