minor bug fix
[openemr.git] / library / classes / WSWrapper.class.php
blob7e4787685d2dd371015709eae63e292efdb7371a
1 <?php
2 require_once(dirname(__FILE__) . "/../freeb/xmlrpc.inc");
3 require_once(dirname(__FILE__) . "/../freeb/xmlrpcs.inc");
5 class WSWrapper {
7 var $_config;
8 var $value;
10 function WSWrapper($function,$send = true) {
11 $this->_config = $GLOBALS['oer_config']['ws_accounting'];
12 //print_r($this->_config);
13 if (!$this->_config['enabled']) return;
15 if ($send) {
16 $this->send($function);
20 function send($function) {
21 list($name,$var) = each($function);
22 $f=new xmlrpcmsg($name,$var);
23 //print "<pre>" . htmlentities($f->serialize()) . "</pre>\n";
24 $c=new xmlrpc_client($this->_config['url'], $this->_config['server'],$this->_config['port']);
25 $c->setCredentials($this->_config['username'],$this->_config['password']);
26 //$c->setDebug(1);
27 $r=$c->send($f);
28 if (!$r) { echo("send failed"); }
29 $tv=$r->value();
30 if (is_object($tv)) {
31 $this->value = $tv->getval();
33 else {
34 $this->value = null;
37 if ($r->faultCode()) {
38 echo "<HR>Fault: ";
39 echo "Code: " . $r->faultCode() . " Reason '" .$r->faultString()."'<BR>";