-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSoapTransporter.php
More file actions
executable file
·95 lines (82 loc) · 2.09 KB
/
Copy pathSoapTransporter.php
File metadata and controls
executable file
·95 lines (82 loc) · 2.09 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Tsp;
use Poirot\ApiClient\Exception\ApiCallException;
use Poirot\ApiClient\Exception\ConnectException;
use Poirot\Connection\AbstractConnection;
use Poirot\Connection\Interfaces\iConnection;
use Poirot\Stream\Streamable;
class SoapTransporter extends AbstractConnection
implements iConnection
{
/** @var \SoapClient */
protected $transporter;
protected $result;
/**
* Get Prepared Resource Transporter
*
* - prepare resource with options
*
* @throws ConnectException
* @return mixed Transporter Resource
*/
function getConnect()
{
if ($this->isConnected())
$this->close();
$wsdlLink = $this->optsData()->getServerUrl();
$soapConfigs = clone $this->optsData();
$soapConfigs->del('server_url');
$soapConfigs = \Poirot\Std\iterator_to_array($soapConfigs);
$transporter = new \SoapClient($wsdlLink, $soapConfigs);
return $this->transporter = $transporter;
}
/**
* Send Expression On the wire
*
* !! get expression from getRequest()
*
* @throws ApiCallException|ConnectException
* @return mixed Response
*/
function doSend()
{
$expr = $this->getRequest();
// call specific endpoint
$methodName = key($expr);
$this->result = $this->transporter->{$methodName}($expr[$methodName]);
return $this->result;
}
/**
* Receive Server Response
*
* - it will executed after a request call to server
* by send expression
* - return null if request not sent
*
* @throws \Exception No Transporter established
* @return null|string|Streamable
*/
function receive()
{
return $this->result;
}
/**
* Is Transporter Resource Available?
*
* @return bool
*/
function isConnected()
{
if(is_null($this->transporter))
return false;
return true;
}
/**
* Close Transporter
* @return void
*/
function close()
{
$this->transporter = null;
}
}