reference/soap/soapclient/construct.xml
497c40ac164d5873fd87f622dfdeb5206392b446
...
...
@@ -1,6 +1,5 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<refentry xml:id="soapclient.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>SoapClient::__construct</refname>
...
...
@@ -9,18 +8,771 @@
9
8

10
9
<refsect1 role="description">
11
10
&reftitle.description;
12
-
<methodsynopsis>
11
+
<constructorsynopsis role="SoapClient">
13
12
<modifier>public</modifier> <methodname>SoapClient::__construct</methodname>
14
-
<methodparam><type>mixed</type><parameter>wsdl</parameter></methodparam>
15
-
<methodparam choice="opt"><type>array</type><parameter>options</parameter></methodparam>
16
-
</methodsynopsis>
13
+
<methodparam><type class="union"><type>string</type><type>null</type></type><parameter>wsdl</parameter></methodparam>
14
+
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
15
+
</constructorsynopsis>
17
16
<para>
18
-
&info.function.alias; <methodname>SoapClient::SoapClient</methodname>
17
+
Creates a <classname>SoapClient</classname> object to connect to a SOAP service.
19
18
</para>
20
19
</refsect1>
21
20

22
-
</refentry>
21
+
<refsect1 role="parameters">
22
+
&reftitle.parameters;
23
+
<para>
24
+
<variablelist>
25
+
<varlistentry>
26
+
<term><parameter>wsdl</parameter></term>
27
+
<listitem>
28
+
<para>
29
+
URI of a WSDL file describing the service, which is used to automatically
30
+
configure the client. If not provided, the client will operate in non-WSDL
31
+
mode.
32
+
</para>
33
+
<note>
34
+
<para>
35
+
By default, the WSDL file will be cached for performance. To disable
36
+
or configure this caching, see
37
+
<link linkend="soap.configuration.list">SOAP &ConfigureOptions;</link>
38
+
and the <link linkend="soapclient.construct.options.cache-wsdl">
39
+
<literal>cache_wsdl</literal> option</link>.
40
+
</para>
41
+
</note>
42
+
</listitem>
43
+
</varlistentry>
44
+
<varlistentry>
45
+
<term><parameter>options</parameter></term>
46
+
<listitem>
47
+
<para>
48
+
An associative array specifying additional options for the SOAP client.
49
+
If <parameter>wsdl</parameter> is provided, this is optional; otherwise,
50
+
at least <literal>location</literal> and <literal>url</literal> must be
51
+
provided.
52
+
<variablelist>
53
+
<varlistentry xml:id="soapclient.construct.options.location">
54
+
<term>
55
+
<parameter>location</parameter>
56
+
<type>string</type>
57
+
</term>
58
+
<listitem>
59
+
<para>
60
+
The URL of the SOAP server to send the request to.
61
+
</para>
62
+
<para>
63
+
Required if the <parameter>wsdl</parameter> parameter is not provided.
64
+
If both a <parameter>wsdl</parameter> parameter and
65
+
<literal>location</literal> option are provided, the
66
+
<literal>location</literal> option will over-ride any location
67
+
specified in the WSDL file.
68
+
</para>
69
+
</listitem>
70
+
</varlistentry>
71
+
<varlistentry xml:id="soapclient.construct.options.uri">
72
+
<term>
73
+
<parameter>uri</parameter>
74
+
<type>string</type>
75
+
</term>
76
+
<listitem>
77
+
<para>
78
+
The target namespace of the SOAP service.
79
+
</para>
80
+
<para>
81
+
Required if the <parameter>wsdl</parameter> parameter is not provided;
82
+
ignored otherwise.
83
+
</para>
84
+
</listitem>
85
+
</varlistentry>
86
+
<varlistentry xml:id="soapclient.construct.options.style">
87
+
<term>
88
+
<parameter>style</parameter>
89
+
<type>int</type>
90
+
</term>
91
+
<listitem>
92
+
<para>
93
+
Specifies the binding style to use for this client, using the constants
94
+
<constant>SOAP_RPC</constant> and <constant>SOAP_DOCUMENT</constant>.
95
+
<constant>SOAP_RPC</constant> indicates RPC-style binding, where the
96
+
SOAP request body contains a standard encoding of a function call.
97
+
<constant>SOAP_DOCUMENT</constant> indicates document-style binding,
98
+
where the SOAP request body contains an XML document with
99
+
service-defined meaning.
100
+
</para>
101
+
<para>
102
+
If the <parameter>wsdl</parameter> parameter is provided, this
103
+
option is ignored, and the style is read from the WSDL file.
104
+
</para>
105
+
<para>
106
+
If neither this option nor the <parameter>wsdl</parameter> parameter
107
+
is provided, RPC-style is used.
108
+
</para>
109
+
</listitem>
110
+
</varlistentry>
111
+
<varlistentry xml:id="soapclient.construct.options.use">
112
+
<term>
113
+
<parameter>use</parameter>
114
+
<type>int</type>
115
+
</term>
116
+
<listitem>
117
+
<para>
118
+
Specifies the encoding style to use for this client, using the
119
+
constants <constant>SOAP_ENCODED</constant> or <constant>SOAP_LITERAL</constant>.
120
+
<constant>SOAP_ENCODED</constant> indicates encoding using the types
121
+
defined in the SOAP specification.
122
+
<constant>SOAP_LITERAL</constant> indicates encoding using a schema
123
+
defined by the service.
124
+
</para>
125
+
<para>
126
+
If the <parameter>wsdl</parameter> parameter is provided, this
127
+
option is ignored, and the encoding is read from the WSDL file.
128
+
</para>
129
+
<para>
130
+
If neither this option nor the <parameter>wsdl</parameter> parameter
131
+
is provided, the "encoded" style is used.
132
+
</para>
133
+
</listitem>
134
+
</varlistentry>
135
+
<varlistentry xml:id="soapclient.construct.options.soap-version">
136
+
<term>
137
+
<parameter>soap_version</parameter>
138
+
<type>int</type>
139
+
</term>
140
+
<listitem>
141
+
<para>
142
+
Specifies the version of the SOAP protocol to use:
143
+
<constant>SOAP_1_1</constant> for SOAP 1.1,
144
+
or <constant>SOAP_1_2</constant> for SOAP 1.2.
145
+
</para>
146
+
<para>
147
+
If omitted, SOAP 1.1 is used.
148
+
</para>
149
+
</listitem>
150
+
</varlistentry>
151
+
<varlistentry xml:id="soapclient.construct.options.authentication">
152
+
<term>
153
+
<parameter>authentication</parameter>
154
+
<type>int</type>
155
+
</term>
156
+
<listitem>
157
+
<para>
158
+
Specifies the authentication method when using HTTP authentication
159
+
in requests. The value may be either
160
+
<constant>SOAP_AUTHENTICATION_BASIC</constant>
161
+
or <constant>SOAP_AUTHENTICATION_DIGEST</constant>.
162
+
</para>
163
+
<para>
164
+
If omitted, and the <literal>login</literal> option is provided,
165
+
Basic Authentication is used.
166
+
</para>
167
+
</listitem>
168
+
</varlistentry>
169
+
<varlistentry xml:id="soapclient.construct.options.login">
170
+
<term>
171
+
<parameter>login</parameter>
172
+
<type>string</type>
173
+
</term>
174
+
<listitem>
175
+
<para>
176
+
Username to use with HTTP Basic or Digest Authentication.
177
+
</para>
178
+
</listitem>
179
+
</varlistentry>
180
+
<varlistentry xml:id="soapclient.construct.options.password">
181
+
<term>
182
+
<parameter>password</parameter>
183
+
<type>string</type>
184
+
</term>
185
+
<listitem>
186
+
<para>
187
+
Password to use with HTTP Basic or Digest Authentication.
188
+
</para>
189
+
<para>
190
+
Not to be confused with <literal>passphrase</literal>,
191
+
which is used with HTTPS Client Certificate authentication.
192
+
</para>
193
+
</listitem>
194
+
</varlistentry>
195
+
<varlistentry xml:id="soapclient.construct.options.local-cert">
196
+
<term>
197
+
<parameter>local_cert</parameter>
198
+
<type>string</type>
199
+
</term>
200
+
<listitem>
201
+
<para>
202
+
Path to a client certificate for use with HTTPS authentication.
203
+
It must be a <acronym>PEM</acronym> encoded file which contains your certificate
204
+
and private key.
205
+
</para>
206
+
<para>
207
+
The file can also include a chain of issuers, which must come
208
+
after the client certificate.
209
+
</para>
210
+
<para>
211
+
Can also be set via
212
+
<link linkend="soapclient.construct.options.stream-context">
213
+
<parameter>stream_context</parameter></link>,
214
+
which also supports specifying a separate private key file.
215
+
</para>
216
+
</listitem>
217
+
</varlistentry>
218
+
<varlistentry xml:id="soapclient.construct.options.passphrase">
219
+
<term>
220
+
<parameter>passphrase</parameter>
221
+
<type>string</type>
222
+
</term>
223
+
<listitem>
224
+
<para>
225
+
Passphrase for the client certificate specified in the
226
+
<literal>local_cert</literal> option.
227
+
</para>
228
+
<para>
229
+
Not to be confused with <literal>password</literal>,
230
+
which is used for Basic or Digest Authentication.
231
+
</para>
232
+
<para>
233
+
Can also be set via
234
+
<link linkend="soapclient.construct.options.stream-context">
235
+
<parameter>stream_context</parameter></link>.
236
+
</para>
237
+
</listitem>
238
+
</varlistentry>
239
+
<varlistentry xml:id="soapclient.construct.options.proxy-host">
240
+
<term>
241
+
<parameter>proxy_host</parameter>
242
+
<type>string</type>
243
+
</term>
244
+
<listitem>
245
+
<para>
246
+
Hostname to use as a proxy server for HTTP requests.
247
+
</para>
248
+
<para>
249
+
The <literal>proxy_port</literal> option must also be specified.
250
+
</para>
251
+
</listitem>
252
+
</varlistentry>
253
+
<varlistentry xml:id="soapclient.construct.options.proxy-port">
254
+
<term>
255
+
<parameter>proxy_port</parameter>
256
+
<type>int</type>
257
+
</term>
258
+
<listitem>
259
+
<para>
260
+
TCP port to use when connecting to the proxy server
261
+
specified in <literal>proxy_host</literal>.
262
+
</para>
263
+
</listitem>
264
+
</varlistentry>
265
+
<varlistentry xml:id="soapclient.construct.options.proxy-login">
266
+
<term>
267
+
<parameter>proxy_login</parameter>
268
+
<type>string</type>
269
+
</term>
270
+
<listitem>
271
+
<para>
272
+
Optional username to authenticate with the proxy server
273
+
specified in <literal>proxy_host</literal>, using HTTP
274
+
Basic Authentication.
275
+
</para>
276
+
</listitem>
277
+
</varlistentry>
278
+
<varlistentry xml:id="soapclient.construct.options.proxy-password">
279
+
<term>
280
+
<parameter>proxy_password</parameter>
281
+
<type>string</type>
282
+
</term>
283
+
<listitem>
284
+
<para>
285
+
Optional password to authenticate with the proxy server
286
+
specified in <literal>proxy_host</literal>, using HTTP
287
+
Basic Authentication.
288
+
</para>
289
+
</listitem>
290
+
</varlistentry>
291
+
<varlistentry xml:id="soapclient.construct.options.compression">
292
+
<term>
293
+
<parameter>compression</parameter>
294
+
<type>int</type>
295
+
</term>
296
+
<listitem>
297
+
<para>
298
+
Enables compression of HTTP SOAP requests and responses.
299
+
</para>
300
+
<para>
301
+
The value should be the bitwise OR of three parts:
302
+
an optional <constant>SOAP_COMPRESSION_ACCEPT</constant>,
303
+
to send an "Accept-Encoding" header; either
304
+
<constant>SOAP_COMPRESSION_GZIP</constant>
305
+
or <constant>SOAP_COMPRESSION_DEFLATE</constant> to indicate
306
+
the compression algorithm to use; and a number between 1 and 9
307
+
to indicate the level of compression to use in the request.
308
+
For example, to enable two-way gzip compression with the maximum
309
+
compression level, use
310
+
<literal>SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9</literal>.
311
+
</para>
312
+
</listitem>
313
+
</varlistentry>
314
+
<varlistentry xml:id="soapclient.construct.options.encoding">
315
+
<term>
316
+
<parameter>encoding</parameter>
317
+
<type>string</type>
318
+
</term>
319
+
<listitem>
320
+
<para>
321
+
Defines the internal character encoding. Requests are always sent
322
+
in UTF-8, and converted to and from this encoding.
323
+
</para>
324
+
</listitem>
325
+
</varlistentry>
326
+
<varlistentry xml:id="soapclient.construct.options.trace">
327
+
<term>
328
+
<parameter>trace</parameter>
329
+
<type>bool</type>
330
+
</term>
331
+
<listitem>
332
+
<para>
333
+
Captures request and response information, which can then be
334
+
accessed with the methods
335
+
<methodname>SoapClient::__getLastRequest</methodname>,
336
+
<methodname>SoapClient::__getLastRequestHeaders</methodname>,
337
+
<methodname>SoapClient::__getLastResponse</methodname>,
338
+
and <methodname>SoapClient::__getLastResponseHeaders</methodname>.
339
+
</para>
340
+
<para>
341
+
If omitted, defaults to &false;
342
+
</para>
343
+
</listitem>
344
+
</varlistentry>
345
+
<varlistentry xml:id="soapclient.construct.options.classmap">
346
+
<term>
347
+
<parameter>classmap</parameter>
348
+
<type>array</type>
349
+
</term>
350
+
<listitem>
351
+
<para>
352
+
Used to map types defined in the WSDL to PHP classes.
353
+
It should be specified as an associative <type>array</type> with
354
+
type names from the WSDL as keys and names of PHP classes as values.
355
+
Note that the type names of an element is not necessarily the same as
356
+
the element (tag) name.
357
+
</para>
358
+
<para>
359
+
The provided class names should always be fully qualified with any
360
+
<link linkend="language.namespaces">namespaces</link>, and never
361
+
start with a leading <literal>\</literal>. The correct form can be
362
+
generated by using
363
+
<link linkend="language.oop5.basic.class.class">::class</link>.
364
+
</para>
365
+
<para>
366
+
Note that when creating a class, the constructor will not be called,
367
+
but magic <link linkend="object.set">__set()</link> and
368
+
<link linkend="object.get">__get()</link> methods for individual
369
+
properties will be.
370
+
</para>
371
+
</listitem>
372
+
</varlistentry>
373
+
<varlistentry xml:id="soapclient.construct.options.typemap">
374
+
<term>
375
+
<parameter>typemap</parameter>
376
+
<type>array</type>
377
+
</term>
378
+
<listitem>
379
+
<para>
380
+
Used to define type mappings using user-defined callback functions.
381
+
Each type mapping should be an array with keys
382
+
<literal>type_name</literal> (<type>string</type> specifying the
383
+
XML element type);
384
+
<literal>type_ns</literal> (<type>string</type> containing namespace
385
+
URI);
386
+
<literal>from_xml</literal> (<type>callable</type> accepting one
387
+
string parameter and returning an object) and
388
+
<literal>to_xml</literal> (<type>callable</type> accepting one
389
+
object parameter and returning a string).
390
+
</para>
391
+
</listitem>
392
+
</varlistentry>
393
+
<varlistentry xml:id="soapclient.construct.options.exceptions">
394
+
<term>
395
+
<parameter>exceptions</parameter>
396
+
<type>bool</type>
397
+
</term>
398
+
<listitem>
399
+
<para>
400
+
Defines whether errors throw exceptions of type
401
+
<classname>SoapFault</classname>.
402
+
</para>
403
+
<para>
404
+
Defaults to &true;
405
+
</para>
406
+
</listitem>
407
+
</varlistentry>
408
+
<varlistentry xml:id="soapclient.construct.options.connection-timeout">
409
+
<term>
410
+
<parameter>connection_timeout</parameter>
411
+
<type>int</type>
412
+
</term>
413
+
<listitem>
414
+
<para>
415
+
Defines a timeout in seconds for the connection to the SOAP service.
416
+
This option does not define a timeout for services with slow responses.
417
+
To limit the time to wait for calls to finish the
418
+
<link linkend="ini.default-socket-timeout">default_socket_timeout</link>
419
+
configuration option is available.
420
+
</para>
421
+
</listitem>
422
+
</varlistentry>
423
+
<varlistentry xml:id="soapclient.construct.options.cache-wsdl">
424
+
<term>
425
+
<parameter>cache_wsdl</parameter>
426
+
<type>int</type>
427
+
</term>
428
+
<listitem>
429
+
<para>
430
+
If the <parameter>wsdl</parameter> parameter is provided, and the
431
+
<link linkend="ini.soap.wsdl-cache-enabled">soap.wsdl_cache_enabled</link>
432
+
configuration option is on, this option determines the type of caching.
433
+
One of <constant>WSDL_CACHE_NONE</constant>,
434
+
<constant>WSDL_CACHE_DISK</constant>,
435
+
<constant>WSDL_CACHE_MEMORY</constant> or
436
+
<constant>WSDL_CACHE_BOTH</constant>.
437
+
</para>
438
+
<para>
439
+
Two types of cache are available: in-memory caching, which caches the WSDL
440
+
in the memory of the current process; and disk caching, which caches the
441
+
WSDL in a file on disk, shared between all processes.
442
+
The directory to use for the disk cache is determined by the
443
+
<link linkend="ini.soap.wsdl-cache-dir">soap.wsdl_cache_dir</link>
444
+
configuration option.
445
+
Both caches use the same lifetime, determined by the
446
+
<link linkend="ini.soap.wsdl-cache-ttl">soap.wsdl_cache_ttl</link>
447
+
configuration option. The in-memory cache also has a maximum number of entries
448
+
determined by the
449
+
<link linkend="ini.soap.wsdl-cache-limit">soap.wsdl_cache_limit</link>
450
+
configuration option.
451
+
</para>
452
+
<para>
453
+
If not specified, the <link linkend="ini.soap.wsdl-cache">
454
+
soap.wsdl_cache</link> configuration option will be used.
455
+
</para>
456
+
</listitem>
457
+
</varlistentry>
458
+
<varlistentry xml:id="soapclient.construct.options.user-agent">
459
+
<term>
460
+
<parameter>user_agent</parameter>
461
+
<type>string</type>
462
+
</term>
463
+
<listitem>
464
+
<para>
465
+
The value to use in the <literal>User-Agent</literal> HTTP header
466
+
when making requests.
467
+
</para>
468
+
<para>
469
+
Can also be set via <link linkend="soapclient.construct.options.stream-context">
470
+
<parameter>stream_context</parameter></link>.
471
+
</para>
472
+
<para>
473
+
If not specified, the user agent will be <literal>"PHP-SOAP/"</literal>
474
+
followed by the value of <constant>PHP_VERSION</constant>.
475
+
</para>
476
+
</listitem>
477
+
</varlistentry>
478
+
<varlistentry xml:id="soapclient.construct.options.stream-context">
479
+
<term>
480
+
<parameter>stream_context</parameter>
481
+
<type>resource</type>
482
+
</term>
483
+
<listitem>
484
+
<para>
485
+
A <link linkend="context">stream context</link> created by
486
+
<function>stream_context_create</function>, which allows additional
487
+
options to be set.
488
+
</para>
489
+
<para>
490
+
The context may include <link linkend="context.socket">socket context options</link>,
491
+
<link linkend="context.ssl">SSL context options</link>,
492
+
plus selected <link linkend="context.http">HTTP context options</link>:
493
+
<literal>content_type</literal>, <literal>header</literal>,
494
+
<literal>max_redirects</literal>, <literal>protocol_version</literal>,
495
+
and <literal>user_agent</literal>.
496
+
</para>
497
+
<para>
498
+
Note that the following HTTP headers are generated automatically or from other
499
+
options, and will be ignored if specified in the <literal>'header'</literal>
500
+
context option: <literal>host</literal>, <literal>connection</literal>,
501
+
<literal>user-agent</literal>, <literal>content-length</literal>,
502
+
<literal>content-type</literal>, <literal>cookie</literal>,
503
+
<literal>authorization</literal>, and <literal>proxy-authorization</literal>
504
+
</para>
505
+
</listitem>
506
+
</varlistentry>
507
+
<varlistentry xml:id="soapclient.construct.options.features">
508
+
<term>
509
+
<parameter>features</parameter>
510
+
<type>int</type>
511
+
</term>
512
+
<listitem>
513
+
<para>
514
+
A bitmask to enable one or more of the following features:
515
+
<variablelist>
516
+
<varlistentry>
517
+
<term>
518
+
<constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant>
519
+
</term>
520
+
<listitem>
521
+
<para>
522
+
When decoding a response to an array, the default behaviour is to detect whether
523
+
an element name appears once or multiple times in a particular parent element.
524
+
For elements which appear only once, an object property allows direct access to
525
+
the content; for elements which appear more than once, the property contains an
526
+
array with the content of each matching element.
527
+
</para>
528
+
<para>
529
+
If the <constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant> feature is enabled,
530
+
elements which appear only once are placed in a single-element array, so that
531
+
access is consistent for all elements. This only has an effect when using a WSDL
532
+
containing a schema for the response. See Examples section for an illustration.
533
+
</para>
534
+
</listitem>
535
+
</varlistentry>
536
+
<varlistentry>
537
+
<term>
538
+
<constant>SOAP_USE_XSI_ARRAY_TYPE</constant>
539
+
</term>
540
+
<listitem>
541
+
<para>
542
+
When the <link linkend="soapclient.construct.options.use"><literal>use</literal>
543
+
option</link> or WSDL property is set to <literal>encoded</literal>,
544
+
force arrays to use a type of <literal>SOAP-ENC:Array</literal>, rather than a
545
+
schema-specific type.
546
+
</para>
547
+
</listitem>
548
+
</varlistentry>
549
+
<varlistentry>
550
+
<term>
551
+
<constant>SOAP_WAIT_ONE_WAY_CALLS</constant>
552
+
</term>
553
+
<listitem>
554
+
<para>
555
+
Wait for a response even if the WSDL indicates a one-way request.
556
+
</para>
557
+
</listitem>
558
+
</varlistentry>
559
+
</variablelist>
560
+
</para>
561
+
</listitem>
562
+
</varlistentry>
563
+
<varlistentry xml:id="soapclient.construct.options.keep-alive">
564
+
<term>
565
+
<parameter>keep_alive</parameter>
566
+
<type>bool</type>
567
+
</term>
568
+
<listitem>
569
+
<para>
570
+
a boolean value defining whether
571
+
to send the <literal>Connection: Keep-Alive</literal> header or
572
+
<literal>Connection: close</literal>.
573
+
</para>
574
+
<para>
575
+
Defaults to &true;
576
+
</para>
577
+
</listitem>
578
+
</varlistentry>
579
+
<varlistentry xml:id="soapclient.construct.options.ssl-method">
580
+
<term>
581
+
<parameter>ssl_method</parameter>
582
+
<type>string</type>
583
+
</term>
584
+
<listitem>
585
+
<para>
586
+
Specifies the SSL or TLS protocol version to use with secure HTTP
587
+
connections, instead of the default negotiation.
588
+
Specifying <constant>SOAP_SSL_METHOD_SSLv2</constant>
589
+
or <constant>SOAP_SSL_METHOD_SSLv3</constant> will force use of SSL 2
590
+
or SSL 3, respectively.
591
+
Specifying <constant>SOAP_SSL_METHOD_SSLv23</constant> has no effect;
592
+
the constant exists only for backwards compatibility.
593
+
As of PHP 7.2, specifying <constant>SOAP_SSL_METHOD_TLS</constant>
594
+
also has no effect; in earlier versions, it forced use of TLS 1.0.
595
+
</para>
596
+
<para>
597
+
Note that SSL versions 2 and 3 are considered insecure, and may not
598
+
be supported by the installed OpenSSL library.
599
+
</para>
600
+
<para>
601
+
This option is <emphasis>DEPRECATED</emphasis> as of PHP 8.1.0.
602
+
A more flexible alternative, which allows specifying
603
+
individual versions of TLS, is to use the
604
+
<link linkend="soapclient.construct.options.stream-context">
605
+
<parameter>stream_context</parameter></link> option with
606
+
the 'crypto_method' context parameter.
607
+
<example>
608
+
<title>Specifying use of TLS 1.3 only</title>
609
+
<programlisting role="php">
610
+
<![CDATA[
611
+
<?php
612
+
$context = stream_context_create([
613
+
'ssl' => [
614
+
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT
615
+
]
616
+
]);
617
+
$client = new SoapClient("some.wsdl", ['context' => $context]);
618
+
]]>
619
+
</programlisting>
620
+
</example>
621
+
</para>
622
+
</listitem>
623
+
</varlistentry>
624
+
</variablelist>
625
+
</para>
626
+
</listitem>
627
+
</varlistentry>
628
+
</variablelist>
629
+
</para>
630
+
</refsect1>
631
+

632
+
<refsect1 role="errors">
633
+
&reftitle.errors;
634
+
<para>
635
+
<methodname>SoapClient::__construct</methodname> will generate an
636
+
<constant>E_ERROR</constant> error if the <literal>location</literal> and
637
+
<literal>uri</literal> options aren't provided in non-WSDL mode.
638
+
</para>
639
+
<para>
640
+
A <classname>SoapFault</classname> exception will be thrown if the
641
+
<parameter>wsdl</parameter> URI cannot be loaded.
642
+
</para>
643
+
</refsect1>
644
+

645
+
<refsect1 role="examples">
646
+
&reftitle.examples;
647
+
<para>
648
+
<example>
649
+
<title>
650
+
<methodname>SoapClient::__construct</methodname> example
651
+
</title>
652
+
<programlisting role="php">
653
+
<![CDATA[
654
+
<?php
655
+

656
+
$client = new SoapClient("some.wsdl");
657
+

658
+
$client = new SoapClient("some.wsdl", array('soap_version' => SOAP_1_2));
659
+

660
+
$client = new SoapClient("some.wsdl", array('login' => "some_name",
661
+
'password' => "some_password"));
662
+

663
+
$client = new SoapClient("some.wsdl", array('proxy_host' => "localhost",
664
+
'proxy_port' => 8080));
665
+

666
+
$client = new SoapClient("some.wsdl", array('proxy_host' => "localhost",
667
+
'proxy_port' => 8080,
668
+
'proxy_login' => "some_name",
669
+
'proxy_password' => "some_password"));
670
+

671
+
$client = new SoapClient("some.wsdl", array('local_cert' => "cert_key.pem"));
672
+

673
+
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
674
+
'uri' => "http://test-uri/"));
23
675

676
+
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
677
+
'uri' => "http://test-uri/",
678
+
'style' => SOAP_DOCUMENT,
679
+
'use' => SOAP_LITERAL));
680
+

681
+
$client = new SoapClient("some.wsdl",
682
+
array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9));
683
+

684
+
$client = new SoapClient("some.wsdl", array('encoding'=>'ISO-8859-1'));
685
+

686
+
class MyBook {
687
+
public $title;
688
+
public $author;
689
+
}
690
+

691
+
$client = new SoapClient("books.wsdl", array('classmap' => array('book' => "MyBook")));
692
+

693
+
$typemap = array(
694
+
array("type_ns" => "http://schemas.example.com",
695
+
"type_name" => "book",
696
+
"from_xml" => "unserialize_book",
697
+
"to_xml" => "serialize_book")
698
+
);
699
+
$client = new SoapClient("books.wsdl", array('typemap' => $typemap));
700
+

701
+
?>
702
+
]]>
703
+
</programlisting>
704
+
</example>
705
+
</para>
706
+

707
+
<para>
708
+
<example>
709
+
<title>Using the <constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant> feature</title>
710
+
<programlisting role="php">
711
+
<![CDATA[
712
+
/* Assuming a response like this, and an appropriate WSDL:
713
+
<?xml version="1.0" encoding="UTF-8"?>
714
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:example">
715
+
<SOAP-ENV:Body>
716
+
<response>
717
+
<collection>
718
+
<item>Single</item>
719
+
</collection>
720
+
<collection>
721
+
<item>First</item>
722
+
<item>Second</item>
723
+
</collection>
724
+
</response>
725
+
</SOAP-ENV:Body>
726
+
</SOAP-ENV:Envelope>
727
+
*/
728
+

729
+
echo "Default:\n";
730
+

731
+
$client = new TestSoapClient(__DIR__ . '/temp.wsdl');
732
+
$response = $client->exampleRequest();
733
+
var_dump( $response->collection[0]->item );
734
+
var_dump( $response->collection[1]->item );
735
+

736
+
echo "\nWith SOAP_SINGLE_ELEMENT_ARRAYS:\n";
737
+

738
+
$client = new TestSoapClient(__DIR__ . '/temp.wsdl', ['features' => SOAP_SINGLE_ELEMENT_ARRAYS]);
739
+
$response = $client->exampleRequest();
740
+
var_dump( $response->collection[0]->item );
741
+
var_dump( $response->collection[1]->item );
742
+
]]>
743
+
</programlisting>
744
+

745
+
&example.outputs;
746
+

747
+
<screen>
748
+
<![CDATA[
749
+
Default:
750
+
string(6) "Single"
751
+
array(2) {
752
+
[0] =>
753
+
string(5) "First"
754
+
[1] =>
755
+
string(6) "Second"
756
+
}
757
+

758
+
With SOAP_SINGLE_ELEMENT_ARRAYS:
759
+
array(1) {
760
+
[0] =>
761
+
string(6) "Single"
762
+
}
763
+
array(2) {
764
+
[0] =>
765
+
string(5) "First"
766
+
[1] =>
767
+
string(6) "Second"
768
+
}
769
+
]]>
770
+
</screen>
771
+
</example>
772
+
</para>
773
+
</refsect1>
774
+

775
+
</refentry>
24
776
<!-- Keep this comment at the end of the file
25
777
Local variables:
26
778
mode: sgml
27
779