1 | <?php |
||
13 | class SoapClient extends \SoapClient |
||
14 | { |
||
15 | /** |
||
16 | * cURL resource used to make the SOAP request |
||
17 | * |
||
18 | * @var resource |
||
19 | */ |
||
20 | protected $ch; |
||
21 | |||
22 | /** |
||
23 | * Options passed to the client constructor. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $options; |
||
28 | |||
29 | /** |
||
30 | * Cache for fetched WSDLs. |
||
31 | * @var array |
||
32 | */ |
||
33 | protected static $wsdlCache = []; |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | * |
||
38 | * Additional options: |
||
39 | * - user (string): The user to authenticate with. |
||
40 | * - password (string): The password to use when authenticating the user. |
||
41 | * - curlopts (array): Array of options to set on the curl handler when |
||
42 | * making the request. |
||
43 | * - strip_bad_chars (boolean, default true): Whether or not to strip |
||
44 | * invalid characters from the XML response. This can lead to content |
||
45 | * being returned differently than it actually is on the host service, but |
||
46 | * can also prevent the "looks like we got no XML document" SoapFault when |
||
47 | * the response includes invalid characters. |
||
48 | * - warn_on_bad_chars (boolean, default false): Trigger a warning if bad |
||
49 | * characters are stripped. This has no affect unless strip_bad_chars is |
||
50 | * true. |
||
51 | */ |
||
52 | public function __construct($wsdl, array $options = []) |
||
75 | |||
76 | /** |
||
77 | * Fetch the WSDL to use. |
||
78 | * |
||
79 | * We need to fetch the WSDL on our own and save it into a file so that the parent class can load it from there. |
||
80 | * This is because the parent class doesn't support overwriting the WSDL fetching code which means we can't add |
||
81 | * the required NTLM handling. |
||
82 | */ |
||
83 | protected function ___fetchWSDL($wsdl) { |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | public function __doRequest($request, $location, $action, $version, $one_way = 0) |
||
139 | |||
140 | /** |
||
141 | * {@inheritdoc} |
||
142 | */ |
||
143 | public function __getLastRequestHeaders() |
||
147 | |||
148 | /** |
||
149 | * Returns the response code from the last request |
||
150 | * |
||
151 | * @return integer |
||
152 | * |
||
153 | * @throws \BadMethodCallException |
||
154 | * If no cURL resource has been initialized. |
||
155 | */ |
||
156 | public function getResponseCode() |
||
166 | |||
167 | /** |
||
168 | * Builds the headers for the request. |
||
169 | * |
||
170 | * @param string $action |
||
171 | * The SOAP action to be performed. |
||
172 | */ |
||
173 | protected function buildHeaders($action) |
||
192 | |||
193 | /** |
||
194 | * Cleans the response body by stripping bad characters if instructed to. |
||
195 | */ |
||
196 | protected function cleanResponse() |
||
223 | |||
224 | /** |
||
225 | * Builds an array of curl options for the request |
||
226 | * |
||
227 | * @param string $action |
||
228 | * The SOAP action to be performed. |
||
229 | * @param string $request |
||
230 | * The XML SOAP request. |
||
231 | * @return array |
||
232 | * Array of curl options. |
||
233 | */ |
||
234 | protected function curlOptions($action, $request) |
||
253 | |||
254 | /** |
||
255 | * Pareses the response from a successful request. |
||
256 | * |
||
257 | * @param string $response |
||
258 | * The response from the cURL request, including headers and body. |
||
259 | */ |
||
260 | public function parseResponse($response) |
||
271 | } |
||
272 |