* Copyright (C) 2012 JF FERRY * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/webservices/demo_wsclient_category.php * \brief Demo page to make a category call to Dolibarr WebServices "server_category" */ // This is to make Dolibarr working with Plesk set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); require_once("../master.inc.php"); require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP $WS_DOL_URL = $dolibarr_main_url_root.'/webservices/server_category.php'; $WS_METHOD = 'getCategory'; // Set the WebService URL dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL); $soapclient = new nusoap_client($WS_DOL_URL); if ($soapclient) { $soapclient->soap_defencoding='UTF-8'; } $soapclient2 = new nusoap_client($WS_DOL_URL); if ($soapclient2) { $soapclient2->soap_defencoding='UTF-8'; } // Call the WebService method and store its result in $result. $authentication=array( 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, 'sourceapplication'=>'DEMO', 'login'=>'admin', 'password'=>'changeme', 'entity'=>''); $parameters = array('authentication'=>$authentication,'id'=>1); dol_syslog("Call method ".$WS_METHOD); $result = $soapclient->call($WS_METHOD,$parameters); if (! $result) { //var_dump($soapclient); print '

Erreur SOAP 1

'.$soapclient->error_str; exit; } /* * View */ header("Content-type: text/html; charset=utf8"); print ''."\n"; echo ''."\n"; echo ''; echo 'WebService Test: '.$WS_METHOD.''; echo ''."\n"; echo ''."\n"; echo "

Request 1:

"; echo '

Function

'; echo $WS_METHOD; echo '

SOAP Message

'; echo '
' . htmlspecialchars($soapclient->request, ENT_QUOTES) . '
'; echo '
'; echo "

Response:

"; echo '

Result

'; echo '
';
print_r($result);
echo '
'; echo '

SOAP Message

'; echo '
' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '
'; echo ''."\n"; echo ''."\n"; ?>