Skip to content
Snippets Groups Projects
Select Git revision
  • 56264f0bf562fd2e0fd0ae69b13ab01e4ec2b9aa
  • 3.9 default
  • develop
  • 6.0
  • 5.0
  • 4.0
  • scrutinizer-patch-4
  • scrutinizer-patch-3
  • scrutinizer-patch-2
  • scrutinizer-patch-1
  • 3.7
  • 3.8
  • 3.6
  • 3.9_backported
  • 3.8_backported
  • 3.7_backported
  • 3.5
  • 3.6_backported
  • 3.5_backported
  • 3.4
  • 3.3_backported
  • 6.0.4
  • 6.0.3
  • 5.0.7
  • 6.0.2
  • 6.0.1
  • 5.0.6
  • 6.0.0
  • 5.0.5
  • 6.0.0-rc
  • 5.0.4
  • 6.0.0-beta
  • 5.0.3
  • 4.0.6
  • 5.0.2
  • 5.0.1
  • 4.0.5
  • 5.0.0
  • 4.0.4
  • 5.0.0-rc2
  • 5.0.0-rc1
41 results

demo_wsclient_other.php

Blame
  • demo_wsclient_other.php 2.91 KiB
    <?php
    /* Copyright (C) 2006-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
     *
     * 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 2 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 <http://www.gnu.org/licenses/>.
     */
    
    /**
     *       \file       htdocs/webservices/demo_wsclient_other.php
     *       \brief      Demo page to make a client call to Dolibarr WebServices "server_other"
     */
    
    // 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 = DOL_MAIN_URL_ROOT.'/webservices/server_other.php';
    //$WS_DOL_URL = 'http://localhost:8080/';	// If not a page, should end with /
    $WS_METHOD  = 'getVersions';
    $ns='http://www.dolibarr.org/ns/';
    
    
    // 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';
    	$soapclient->decodeUTF8(false);
    }
    
    // Call the WebService method and store its result in $result.
    $authentication=array(
        'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
        'sourceapplication'=>'DEMO',
        'login'=>'admin',
        'password'=>'changeme',
        'entity'=>'');
    
    // Test URL
    if ($WS_METHOD)
    {
        $parameters = array('authentication'=>$authentication);
        dol_syslog("Call method ".$WS_METHOD);
        $result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
        if (! $result)
        {
        	//var_dump($soapclient);
        	//print_r($soapclient);
        	print $soapclient->error_str;
        	print "<br>\n\n";
        	print $soapclient->request;
        	print "<br>\n\n";
        	print $soapclient->response;
        	exit;
        }
    }
    
    
    /*
     * View
     */
    
    header("Content-type: text/html; charset=utf8");
    print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
    echo '<html>'."\n";
    echo '<head>';
    echo '<title>WebService Test: '.$WS_METHOD.'</title>';
    echo '</head>'."\n";
    
    echo '<body>'."\n";
    echo 'NUSOAP_PATH='.NUSOAP_PATH.'<br>';
    
    echo "<h2>Request:</h2>";
    echo '<h4>Function</h4>';
    echo $WS_METHOD;
    echo '<h4>SOAP Message</h4>';
    echo '<pre>' . htmlspecialchars($soapclient->request, ENT_QUOTES) . '</pre>';
    
    echo '<hr>';
    
    echo "<h2>Response:</h2>";
    echo '<h4>Result</h4>';
    echo '<pre>';
    print_r($result);
    echo '</pre>';
    echo '<h4>SOAP Message</h4>';
    echo '<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>';
    
    echo '</body>'."\n";;
    echo '</html>'."\n";;
    ?>