-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathClientEncoder.php
More file actions
72 lines (62 loc) · 2.04 KB
/
Copy pathClientEncoder.php
File metadata and controls
72 lines (62 loc) · 2.04 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
<?php
namespace Clue\React\Soap\Protocol;
use Psr\Http\Message\RequestInterface;
use Laminas\Diactoros\Request;
use Laminas\Diactoros\StreamFactory;
/**
* @internal
*/
final class ClientEncoder extends \SoapClient
{
private $request = null;
/**
* Encodes the given RPC function name and arguments as a SOAP request
*
* @param string $name
* @param array $args
* @return RequestInterface
* @throws \SoapFault if request is invalid according to WSDL
*/
public function encode(string $name, array $args): RequestInterface
{
$this->__soapCall($name, $args);
$request = $this->request;
$this->request = null;
return $request;
}
/**
* Overwrites the internal request logic to build the request message
*
* By overwriting this method, we can skip the actual request sending logic
* and still use the internal request serializing logic by accessing the
* given `$request` parameter and building our custom request object from
* it. We skip/ignore its parsing logic by returing an empty response here.
* This will implicitly be invoked by the call to `__soapCall()` in the
* above `encode()` method.
*
* @see \SoapClient::__doRequest()
*/
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$headers = array();
if ($version === SOAP_1_1) {
$headers = array(
'SOAPAction' => $action,
'Content-Type' => 'text/xml; charset=utf-8'
);
} elseif ($version === SOAP_1_2) {
$headers = array(
'Content-Type' => 'application/soap+xml; charset=utf-8; action=' . $action
);
}
$body = (new StreamFactory())->createStream((string)$request);
$this->request = new Request(
(string)$location,
'POST',
$body,
$headers
);
// do not actually block here, just pretend we're done...
return '';
}
}