-
Notifications
You must be signed in to change notification settings - Fork 11
/
Client.php
64 lines (57 loc) · 1.36 KB
/
Client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace mongosoft\soapclient;
use SoapClient;
use SoapFault;
use yii\base\Component;
use yii\base\InvalidConfigException;
/**
* The SOAP Client class.
*
* Note, PHP SOAP extension is required.
*
* @author Alexander Mohorev <[email protected]>
*/
class Client extends Component
{
/**
* @var string $url the URL of the WSDL file.
*/
public $url;
/**
* @var array the array of SOAP client options.
*/
public $options = [];
/**
* @var SoapClient the SOAP client instance.
*/
private $_client;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->url === null) {
throw new InvalidConfigException('The "url" property must be set.');
}
try {
$this->_client = new SoapClient($this->url, $this->options);
} catch (SoapFault $e) {
throw new Exception($e->getMessage(), (int) $e->getCode(), $e);
}
}
/**
* @param string $name
* @param array $arguments
* @return mixed
* @throws Exception
*/
public function __call($name, $arguments)
{
try {
return call_user_func_array([$this->_client, $name], $arguments);
} catch (SoapFault $e) {
throw new Exception($e->getMessage(), (int) $e->getCode(), $e);
}
}
}