6.0.0-git
2019-11-13

Diff for WSDLHowTo between 5 and 6

+ Using WSDLSOAP/WSDL to Interface with the Horde API



Most Horde modules have an API interface which is used by other modules to access and exchange data.  These API's are described in the //modulename/lib/api.php// files.  Calling the ///rpc.php// in your Horde webroot allows you to access the API remotely via XML-RPC/DISCO/SOAP/WSDL/REST etc.   The following script describes how to access a Horde installation remotely and list the APIs that are available.


Most Horde modules have an API interface which is used by other modules to access and exchange data.  These API's are described in the //modulename/lib/api.php// files.  Calling the ///rpc.php// in your Horde webroot allows you to access the API remotely via XML-RPC/DISCO/SOAP/WSDL/REST etc.   The following script describes how to access a Horde installation remotely and list the APIs that are available.

If you have IMP/Turba installed you can also try these calls which are commented out in the script:

<code type="php">

$test = print_r($client->contacts_sources(0, true), 1);

$test = print_r($client->mail_folderlist(), 1);

</code>

For further information, refer to the http://dev.horde.org/ 



<code type="htmlphp">

<html>

<head><title>Horde WSDL Test</title></head>

<body>

<?php

// By <vijay.mahrra / es.easynet.net>

require_once 'SOAP/Client.php';

$horde_user = @$_POST['user'];

$horde_pass = @$_POST['pass'];

$horde_baseurl = @$_POST['url'];

?>

<h1>Horde Installation Details</h1>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">

Horde Base Url <input type="text" name="url" type="text" size="80" value="<?php echo $horde_baseurl ?>"/> Required<br />

Username <input type="text" name="user" size="20" value="<?php echo $horde_user ?>"/><br />

Password <input type="password" name="pass" size="20" value="<?php echo $horde_pass ?>"/><br />

<input type="submit"><br />

</form>

<?php

if (!empty($horde_baseurl)) {

    $wsdl_url = $horde_baseurl . '/rpc.php?wsdl';

    $wsdl =& new SOAP_WSDL($wsdl_url, array('user' => $horde_user, 'pass' => $horde_pass));

    if (is_a($wsdl, 'PEAR_Error')) {

        echo "<pre>" . print_r($wsdl, 1);

        $proxy_code = $wsdl->getMessage();

    } else {

        $proxy_code = highlight_string($wsdl->generateProxyCode(), 1);



        $client = $wsdl->getProxy();

        if (is_a($client, 'PEAR_Error')) {

            $client = $client->getMessage();

        } else {

            $client = print_r($client, 1);

        }
        }
        $client = new WebService_hordeService_hordePort();

        if (!empty($horde_user) && !empty($horde_pass)) {

            $test = print_r($client->horde_listAPIs(), 1);

            //$test = print_r($client->contacts_sources(0, true), 1);

            //$test = print_r($client->mail_folderlist(), 1);

        }

    }

    }

    // write to the html page

    $content = <<<END

<h1>Horde RPC Test</h1>

<ul>

    <li><a href="#wsdl">WSDL</a></li>

    <li><a href="#proxy">Proxy</a></li>

    <li><a href="#listing">Listing</a></li>

    <li><a href="#client">Client</a></li>

    <li><a href="#test">Test</a></li>

</ul>

<hr />

<h2><a name="wsdl">WSDL Document</a> <a class="helplink" href="$wsdl_url">$wsdl_url</a></h2>

<pre>$wsdl_data</pre>

<hr<hr />

<h2><a name="proxy">Proxy Code</a></h2>

$proxy_code

<hr />

<h2><a name="test">Test</a></h2>

<pre>$test</pre>

<hr<hr />

END;

    echo($content);

}

$listing = highlight_file($_SERVER["SCRIPT_FILENAME"], 1);

?>

<h2><a name="listing">Script Code</a></h2>

<?php echo($listing); ?>

<hr />

</body>

</html>

</code>