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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
<HTML>
<HEAD>
<TITLE>PHP SOAP Manual</TITLE>
<STYLE>
TR{
vertical-align: "top";
}
TH{
text-align: "left";
}
TD:{
text-align: "left";
}
</STYLE>
</HEAD>
<BODY>
<A name="ref.soap">
<H1>PHP SOAP</H1>
<H2>Introduction</H2>
<TABLE BORDER="1">
<TR><TD ALIGN="center"><B>Warning</B></TD></TR>
<TR><TD ALIGN="left">This extension is <I>EXPERIMENTAL</I>. The behaviour of this extension -- including the names of its functions and anything else documented about this extension -- may change without notice in a future release of PHP. Use this extension at your own risk.
</TD></TR>
</TABLE>
<I>FIXME</I>
<HR>
<H2>Requirements</H2>
This extension makes use of the <A HREF="http://www.xmlsoft.org" TARGET="_top">GNOME XML library</A>. Download and install this library. You will need at least libxml-2.5.4.
<HR>
<H2>Installation</H2>
This extension is only available if PHP was configured with --enable-soap.
<HR>
<H2>Predefined Constants</H2>
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
<TABLE BORDER="1">
<TR><TH>Constant</TH><TH>Value</TH><TH>Description</TH></TR>
<TR><TH>SOAP_1_1 (integer)</TH><TD>1</TD><TD>SOAP version - SOAP 1.1. Can be used as an option in SoapClient and SoapServer constructors.</TD></TR>
<TR><TH>SOAP_1_2 (integer)</TH><TD>2</TD><TD>SOAP version - SOAP 1.2. Can be used as an option in SoapClient and SoapServer constructors.</TD></TR>
<TR><TH>SOAP_FUNCTIONS_ALL (integer)</TH><TD>999</TD><TD>Allows to export all defined functions with SoapClient::addFunction</TD></TR>
<TR><TH>SOAP_PERSISTENCE_SESSION (integer)</TH><TD>1</TD><TD>Allows making class passed to SoapServer::setClass persistent for a PHP session.</TD></TR>
<TR><TH>SOAP_PERSISTENCE_REQUEST (integer)</TH><TD>2</TD><TD>Allows making class passed to SoapServer::setClass non-persistent for a PHP session.</TD></TR>
<TR><TH>SOAP_ENCODED (integer)</TH><TD>1</TD><TD>Can be passed as <b>style</b> option to SoapClient constructor in nonWSDL mode.</TD></TR>
<TR><TH>SOAP_LITERAL (integer)</TH><TD>2</TD><TD>Can be passed as <b>style</b> option to SoapClient constructor in nonWSDL mode.</TD></TR>
<TR><TH>SOAP_RPC (integer)</TH><TD>1</TD><TD>Can be passed as <b>use</b> option to SoapClient constructor in nonWSDL mode.</TD></TR>
<TR><TH>SOAP_DOCUMENT (integer)</TH><TD>2</TD><TD>Can be passed as <b>use</b> option to SoapClient constructor in nonWSDL mode.</TD></TR>
<TR><TH>SOAP_ACTOR_NEXT (integer)</TH><TD>1</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor.</TD></TR>
<TR><TH>SOAP_ACTOR_NONE (integer)</TH><TD>2</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor</TD></TR>
<TR><TH>SOAP_ACTOR_UNLIMATERECEIVER (integer)</TH><TD>3</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor</TD></TR>
<TR><TH>UNKNOWN_TYPE (integer)</TH><TD>999998</TD><TD>Encoding for unknown type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_STRING (integer)</TH><TD>101</TD><TD>Encoding for standard XMLSchema <b>string</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_BOOLEAN (integer)</TH><TD>102</TD><TD>Encoding for standard XMLSchema <b>boolen</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_DECIMAL (integer)</TH><TD>103</TD><TD>Encoding for standard XMLSchema <b>decimal</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_FLOAT (integer)</TH><TD>104</TD><TD>Encoding for standard XMLSchema <b>float</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_DOUBLE (integer)</TH><TD>105</TD><TD>Encoding for standard XMLSchema <b>double</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_DURATION (integer)</TH><TD>106</TD><TD>Encoding for standard XMLSchema <b>duration</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_DATETIME (integer)</TH><TD>107</TD><TD>Encoding for standard XMLSchema <b>dateTime</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_TIME (integer)</TH><TD>108</TD><TD>Encoding for standard XMLSchema <b>time</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_DATE (integer)</TH><TD>109</TD><TD>Encoding for standard XMLSchema <b>data</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_GYEARMONTH (integer)</TH><TD>110</TD><TD>Encoding for standard XMLSchema <b>gYearMonth</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_GYEAR (integer)</TH><TD>111</TD><TD>Encoding for standard XMLSchema <b>gYear</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_GMONTHDAY (integer)</TH><TD>112</TD><TD>Encoding for standard XMLSchema <b>gMonthDay</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_GDAY (integer)</TH><TD>113</TD><TD>Encoding for standard XMLSchema <b>gDay</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_GMONTH (integer)</TH><TD>114</TD><TD>Encoding for standard XMLSchema <b>gMonth</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_HEXBINARY (integer)</TH><TD>115</TD><TD>Encoding for standard XMLSchema <b>hexBinary</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_BASE64BINARY (integer)</TH><TD>116</TD><TD>Encoding for standard XMLSchema <b>base64Binary</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_ANYURI (integer)</TH><TD>117</TD><TD>Encoding for standard XMLSchema <b>anyURI</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_QNAME (integer)</TH><TD>118</TD><TD>Encoding for standard XMLSchema <b>QName</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NOTATION (integer)</TH><TD>119</TD><TD>Encoding for standard XMLSchema <b>NOTATION</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NORMALIZEDSTRING (integer)</TH><TD>120</TD><TD>Encoding for standard XMLSchema <b>normalizedString</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_TOKEN (integer)</TH><TD>121</TD><TD>Encoding for standard XMLSchema <b>token</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_LANGUAGE (integer)</TH><TD>122</TD><TD>Encoding for standard XMLSchema <b>language</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NMTOKEN (integer)</TH><TD>123</TD><TD>Encoding for standard XMLSchema <b>NMTOKEN</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NAME (integer)</TH><TD>124</TD><TD>Encoding for standard XMLSchema <b>Name</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NCNAME (integer)</TH><TD>125</TD><TD>Encoding for standard XMLSchema <b>NCName</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_ID (integer)</TH><TD>126</TD><TD>Encoding for standard XMLSchema <b>ID</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_IDREF (integer)</TH><TD>127</TD><TD>Encoding for standard XMLSchema <b>IDREF</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_IDREFS (integer)</TH><TD>128</TD><TD>Encoding for standard XMLSchema <b>IDREFS</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_ENTITY (integer)</TH><TD>129</TD><TD>Encoding for standard XMLSchema <b>ENTITY</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_ENTITIES (integer)</TH><TD>130</TD><TD>Encoding for standard XMLSchema <b>ENTITIES</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_INTEGER (integer)</TH><TD>131</TD><TD>Encoding for standard XMLSchema <b>integer</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NONPOSITIVEINTEGER (integer)</TH><TD>132</TD><TD>Encoding for standard XMLSchema <b>nonPositiveInteger</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NEGATIVEINTEGER (integer)</TH><TD>133</TD><TD>Encoding for standard XMLSchema <b>negativeInteger</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_LONG (integer)</TH><TD>134</TD><TD>Encoding for standard XMLSchema <b>long</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_INT (integer)</TH><TD>135</TD><TD>Encoding for standard XMLSchema <b>int</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_SHORT (integer)</TH><TD>136</TD><TD>Encoding for standard XMLSchema <b>short</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_BYTE (integer)</TH><TD>137</TD><TD>Encoding for standard XMLSchema <b>byte</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NONNEGATIVEINTEGER (integer)</TH><TD>138</TD><TD>Encoding for standard XMLSchema <b>nonNegativeInteger</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_UNSIGNEDLONG (integer)</TH><TD>139</TD><TD>Encoding for standard XMLSchema <b>unsignedLong</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_UNSIGNEDINT (integer)</TH><TD>140</TD><TD>Encoding for standard XMLSchema <b>unsignedInt</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_UNSIGNEDSHORT (integer)</TH><TD>141</TD><TD>Encoding for standard XMLSchema <b>unsignedShort</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_UNSIGNEDBYTE (integer)</TH><TD>142</TD><TD>Encoding for standard XMLSchema <b>unsignedByte</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_POSITIVEINTEGER (integer)</TH><TD>143</TD><TD>Encoding for standard XMLSchema <b>positiveInteger</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NMTOKENS (integer)</TH><TD>144</TD><TD>Encoding for standard XMLSchema <b>NMTOKENS</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_ANYTYPE (integer)</TH><TD>145</TD><TD>Encoding for standard XMLSchema <b>anyType</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>SOAP_ENC_ARRAY (integer)</TH><TD>300</TD><TD>Encoding for SOAP <b>Array</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>SOAP_ENC_OBJECT (integer)</TH><TD>301</TD><TD>Encoding for SOAP <b>Struct</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_1999_TIMEINSTANT (integer)</TH><TD>401</TD><TD>Encoding for old XMLSchema <b>timeInstant</b> type. Can be passed to SoapVar constructor.</TD></TR>
<TR><TH>XSD_NAMESPACE (string)</TH><TD> </TD><TD>The XML Schema namespace.</TD></TR>
<TR><TH>XSD_1999_NAMESPACE (string)</TH><TD> </TD><TD>The old XML Schema namespace.</TD></TR>
</TABLE>
<HR>
<H2>Classes</H2>
<h4>List of classes</h4>
<table border="0">
<tr><td><a href="#ref.soap.soapclient">SoapClient</a></td></tr>
<tr><td><a href="#ref.soap.soapserver">SoapServer</a></td></tr>
<tr><td><a href="#ref.soap.soapparam">SoapParam</a></td></tr>
<tr><td><a href="#ref.soap.soapvar">SoapVar</a></td></tr>
<tr><td><a href="#ref.soap.soapheader">SoapHeader</a></td></tr>
<tr><td><a href="#ref.soap.soapfault">SoapFault</a></td></tr>
</table>
<a name="ref.soap.soapclient">
<h4>SoapClient class</h4>
A SOAP client, that allows calling remote methods on SOAP WebService over HTTP
or HTTPS.
<table border="0">
<tr><td><a href="#ref.soap.soapclient.soapclient">SoapClient</a> -- SoapClient constructor</td></tr>
<tr><td><a href="#ref.soap.soapclient.__call">__call</a> -- calls a SOAP function</td></tr>
<tr><td><a href="#ref.soap.soapclient.__getlastrequest">__getLastRequest</a> -- returns last SOAP request</td></tr>
<tr><td><a href="#ref.soap.soapclient.__getlastresponse">__getLastResponse</a> -- returns last SOAP response</td></tr>
<tr><td><a href="#ref.soap.soapclient.__getfunctions">__getFunctions</a> -- returns list of SOAP functions</td></tr>
<tr><td><a href="#ref.soap.soapclient.__gettypes">__getTypes</a> -- returns list of SOAP types</td></tr>
</table>
<a name="ref.soap.soapserver">
<h4>SoapServer class</h4>
This class can be used to build SOAP WebServices, which can be accessed from
remote SOAP clients over HTTP or HTTPS.
<table border="0">
<tr><td><a href="#ref.soap.soapserver.soapserver">SoapServer</a> -- SoapServer constructor</td></tr>
<tr><td><a href="#ref.soap.soapserver.addfunction">addFunction</a> -- adds one or several functions those will handle SOAP requests</td></tr>
<tr><td><a href="#ref.soap.soapserver.setclass">setClass</a> -- sets class which will handle SOAP requests</td></tr>
<tr><td><a href="#ref.soap.soapserver.getfunctions">getFunctions</a> -- returns list of defined functions</td></tr>
<tr><td><a href="#ref.soap.soapserver.setpersistence">setPersistence</a> -- sets persistence mode of SoapServer</td></tr>
<tr><td><a href="#ref.soap.soapserver.handle">handle</a> -- handles a SOAP request</td></tr>
<tr><td><a href="#ref.soap.soapserver.fault">fault</a> -- generates SOAP fault response</td></tr>
</table>
<a name="ref.soap.soapparam">
<h4>SoapParam class</h4>
<p>
SoapParam is a special low-level class for naming parameters and return values
in nonWSDL mode. It is just a data holder and it has not any special method
except constructor.
</p>
<table border="0">
<tr><td><a href="#ref.soap.soapparam.soapparam">SoapParam</a> -- SoapParam constructor</td></tr>
</table>
<a name="ref.soap.soapvar">
<h4>SoapVar classes</h4>
<p>
SoapVar is a special low-level class for encoding parameters and return values
in nonWSDL mode. It is just a data holder and it has not any special method
except constructor. It is useful when you like to set type property in SOAP
request or response.
</p>
<table border="0">
<tr><td><a href="#ref.soap.soapvar.soapvar">SoapVar</a> -- SoapVar constructor</td></tr>
</table>
<a name="ref.soap.soapheader">
<h4>SoapHeader class</h4>
<p>
SoapHeader is a special low-level class for passing or returning SOAP headers.
It is just a data holder and it has not any special method except constructor.
</p>
<table border="0">
<tr><td><a href="#ref.soap.soapheader.soapheader">SoapHeader</a> -- SoapHeader constructor</td></tr>
</table>
<a name="ref.soap.soapfault">
<h4>SoapFault class</h4>
<p>
SoapFault is a special class that can be used for error reporting during
handling of SOAP request (on server). It has not any special methods except
constructor.
</p>
<table border="0">
<tr><td><a href="#ref.soap.soapfault.soapfault">SoapFault</a> -- SoapFault constructor</td></tr>
</table>
<HR>
<!--
<H2>Examples</H2>
-->
<h4>Table of Contents</h4>
<table border="0">
<tr><td><a href="#ref.soap.is_soap_fault">is_soap_fault</a> -- checks if SOAP call was failed</td></tr>
<tr><td><a href="#ref.soap.soapclient.soapclient">SoapClient::SoapClient</a> -- SoapClient constructor</td></tr>
<tr><td><a href="#ref.soap.soapclient.__call">SoapClient::__call</a> -- calls a SOAP function</td></tr>
<tr><td><a href="#ref.soap.soapclient.__getlastrequest">SoapClient::__getLastRequest</a> -- returns last SOAP request</td></tr>
<tr><td><a href="#ref.soap.soapclient.__getlastresponse">SoapClient::__getLastResponse</a> -- returns last SOAP response</td></tr>
<tr><td><a href="#ref.soap.soapclient.__getfunctions">SoapClient::__getFunctions</a> -- returns list of SOAP functions</td></tr>
<tr><td><a href="#ref.soap.soapclient.__gettypes">SoapClient::__getTypes</a> -- returns list of SOAP types</td></tr>
<tr><td><a href="#ref.soap.soapserver.soapserver">SoapServer::SoapServer</a> -- SoapServer constructor</td></tr>
<tr><td><a href="#ref.soap.soapserver.addfunction">SoapServer::addFunction</a> -- adds one or several functions those will handle SOAP requests</td></tr>
<tr><td><a href="#ref.soap.soapserver.setclass">SoapServer::setClass</a> -- sets class which will handle SOAP requests</td></tr>
<tr><td><a href="#ref.soap.soapserver.getfunctions">SoapServer::getFunctions</a> -- returns list of defined functions</td></tr>
<tr><td><a href="#ref.soap.soapserver.setpersistence">SoapServer::setPersistence</a> -- sets persistence mode of SoapServer</td></tr>
<tr><td><a href="#ref.soap.soapserver.handle">SoapServer::handle</a> -- handles a SOAP request</td></tr>
<tr><td><a href="#ref.soap.soapserver.fault">SoapServer::fault</a> -- generates SOAP fault response</td></tr>
<tr><td><a href="#ref.soap.soapparam.soapparam">SoapParam::SoapParam</a> -- SoapParam constructor</td></tr>
<tr><td><a href="#ref.soap.soapvar.soapvar">SoapVar::SoapVar</a> -- SoapVar constructor</td></tr>
<tr><td><a href="#ref.soap.soapheader.soapheader">SoapHeader::SoapHeader</a> -- SoapHeader constructor</td></tr>
<tr><td><a href="#ref.soap.soapfault.soapfault">SoapFault::SoapFault</a> -- SoapFault constructor</td></tr>
</table>
<a name="ref.soap.is_soap_fault"></a>
<h2>is_soap_fault</h2>
<p>(PHP 5)</p>
<p>checks if SOAP call was failed</p>
<h3>Description</h3>
<p>bool <b>is_soap_fault</b>(mixed obj)</p>
<p>
This function is useful when you like to check if the SOAP call was failed.
In this case SOAP method returns a special SoapFault object which encapsulate
the fault details (faultcode, faultstring, faultactor and faultdetails).
is_soap_fault() functions checks if the given parameter is a SoapFault object.
</p>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
$client = SoapClient("some.wsdl");
$result = $client->SomeFunction(...);
if (is_soap_fault($result)) {
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faulstring})", E_ERROR);
}
?></PRE></TD></TR></TABLE>
<a name="ref.soap.soapclient.soapclient"></a>
<h2>SoapClient::SoapClient</h2>
<p>(PHP 5)</p>
<p>SoapClient constructor</p>
<h3>Description</h3>
<p><b>SoapClient</b>(mixed wsdl [, array options])</p>
<p>
The constructor allows creating SoapClient objects in WSDL or nonWSDL mode.
The first case requires URI of WSDL file as first parameter and optional
options array. The second case requires NULL as first parameter and options
array with <b>location</b> and <b>uri</b> options set. Where <b>location</b> is
a URL to request and <b>uri</b> is a target namespace of the SOAP service.
<b>style</b> and <b>use</b> options has effect only on nonWSDL (in WSDL mode
they comes from WSDL file). <b>soap_version</b> option allows to work as SOAP 1.1 or
SOAP 1.2 client.
Some additional optional options allow using HTTP authentication (<b>login</b>
and <b>password</b>) and HTTP connection through proxy server (<b>proxy_host</b>,
<b>proxy_port</b>, <b>proxy_login</b> and <b>proxy_password</b>).
</p>
<h4>Examples</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
$client = new SoapClient("some.wsdl");
$client = new SoapClient("some.wsdl",array('soap_version' => SOAP_1_2));
$client = new SoapClient("some.wsdl",array('login' => "some_name",
'password' => "some_password"));
$client = new SoapClient("some.wsdl",array('proxy_host' => "localhost",
'proxy_port' => 8080));
$client = new SoapClient("some.wsdl",array('proxy_host' => "localhost",
'proxy_port' => 8080,
'proxy_login' => "some_name",
'proxy_password' => "some_password"));
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/",
'style' => SOAP_DOCUMENT,
'use' => SOAP_LITERAL));
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapclient.__call"></a>
<h2>SoapClient::__call</h2>
<p>(PHP 5)</p>
<p>calls a SOAP function</p>
<h3>Description</h3>
<p>mixed <b>__call</b>(string function_name, array arguments, [array options [, mixed input_headers [, mixed &output_headers]]])</p>
<p>
This is a low level API function to make a SOAP call. Usually in WSDL mode
you can simple call SOAP functions as SoapClient methods. It is useful for
nonWSDL mode when 'soapaction' is unknown, 'uri' is differ form default or
when ypu like to send and/or receive SOAP Headers. To check if function call
is failed check the result with is_soap_fault() function.<br>
SOAP function may return one or several values. In the first case __call will
return just the value of output parameter, in the second it will return
array with named output parameters.
</p>
<h4>Examples</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
$client = new SoapClient("some.wsdl");
$client->SomeFunction($a,$b,$c);
$client->__call("SomeFunction",array($a,$b,$c));
$client->__call("SomeFunction",array($a,$b,$c), NULL,
new SoapHeader(...), $output_headers);
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));
$client->SomeFunction($a,$b,$c);
$client->__call("SomeFunction",array($a,$b,$c));
$client->__call("SomeFunction",array($a,$b,$c),
array('soapaction' => 'some_action',
'uri' => 'some_uri'));
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapclient.__getlastrequest"></a>
<h2>SoapClient::__getLastRequest</h2>
<p>(PHP 5)</p>
<p>returns last SOAP request</p>
<h3>Description</h3>
<p>string <b>__getLastRequest</b>()</p>
<p>
This function works only with SoapClient which was created with trace option.
</p>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
$client = SoapClient("some.wsdl", array('trace'=>1));
$result = $client->SomeFunction(...);
echo "REQUEST:\n".$client->__getLastRequest()."\n";
?>
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapclient.__getlastresponse"></a>
<h2>SoapClient::__getLastResponse</h2>
<p>(PHP 5)</p>
<p>returns last SOAP response</p>
<h3>Description</h3>
<p>string <b>__getLastResponse</b>()</p>
<p>
This function works only with SoapClient which was created with trace option.
</p>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
$client = SoapClient("some.wsdl", array('trace'=>1));
$result = $client->SomeFunction(...);
echo "RESPONSE:\n".$client->__getLastResponse()."\n";
?>
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapclient.__getfunctions"></a>
<h2>SoapClient::__getFunctions</h2>
<p>(PHP 5)</p>
<p>returns list of SOAP functions</p>
<h3>Description</h3>
<p>array <b>__getFunctions</b>()</p>
<p>
This function works only in WSDL mode.
</p>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
$client = SoapClient("some.wsdl");
var_dump($client->__getFunctions());
?>
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapclient.__gettypes"></a>
<h2>SoapClient::__getTypes</h2>
<p>(PHP 5)</p>
<p>returns list of SOAP types</p>
<h3>Description</h3>
<p>array <b>__getTypes</b>()</p>
<p>
This function works only in WSDL mode.
</p>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
$client = SoapClient("some.wsdl");
var_dump($client->__getTypes());
?>
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapserver.soapserver"></a>
<h2>SoapServer::SoapServer</h2>
<p>(PHP 5)</p>
<p>SoapServer constructor</p>
<h3>Description</h3>
<p><b>SoapServer</b>(mixed wsdl [, array options])</p>
It allows creating SoapServer objects in WSDL or nonWSDL mode. In the first
case <b>wsdl</b> must be set to URI of WSDL file. In the second <b>wsdl</b>
must be set to null and <b>uti</b> option must be set. Additional options
allow setting a default SOAP version (<b>soap_version</b>) and actor URI
(<b>actor</b>).
<h4>Examples</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
$server = new SoapServer("some.wsdl");
$server = new SoapServer("some.wsdl",array('soap_version'=>SOAP_1_2));
$server = new SoapServer("some.wsdl",array('actor'=>"http://example.org/ts-tests/C"));
$server = new SoapServer(null,array('uri'=>"http://test-uri/"));
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapserver.addfunction">
<h2>SoapServer::addFunction</h2>
<p>(PHP 5)</p>
<p>adds one or several functions those will handle SOAP requests</p>
<h3>Description</h3>
<p>void <b>addFunction</b>(mixed functions)</p>
Exports one or more functions for remote clients. To export one function pass
function name into <b>functions</b> parameter as string. To export several
functions pass an array of function names and to export all functions pass
a special constant <b>SOAP_FUNCTIONS_ALL</b>.<br>
Functions must receive all input arguments in the same order as defined
in WSDL file (They should not receive any output parameters as arguments) and
return one or more values. To return several values they must return array with
named output parameters.
<h4>Examples</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
function func($inputString) {
return $inputString;
}
$server->addFunction("echoString");
function echoTwoStrings($inputString1, $inputString2) {
return array("outputString1"=>$inputString1,"outputString2"=>$inputString2);
}
$server->addFunction(array("echoString","echoTwoStrings"));
$server->addFunction(SOAP_FUNCTIONS_ALL);
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapserver.setclass"></a>
<h2>SoapServer::setClass</h2>
<p>(PHP 5)</p>
<p>sets class which will handle SOAP requests</p>
<h3>Description</h3>
<p>void <b>setClass</b>(string class_name [, ...])</p>
Exports all methods from specified class. Additional parameters will be passed
to default class constructor during object creation. The object can be maiden
persistent across request for a given PHP session with
<a href="#ref.soap.soapserver.setpersistence">SoapServer::setPersistence</a> method.
<h4>Examples</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
$server->setClass("foo");
$server->setClass("foo", $arg1, $arg2);
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapserver.getfunctions">
<h2>SoapServer::getFunctions</h2>
<p>(PHP 5)</p>
<p>returns list of defined functions</p>
<h3>Description</h3>
<p>array <b>getFunctions</b>()</p>
<a name="ref.soap.soapserver.setpersistence"></a>
<h2>SoapServer::setPersistence</h2>
<p>(PHP 5)</p>
<p>sets persistence mode of SoapServer</p>
<h3>Description</h3>
<p>void <b>setPersistence</b>(int mode)</p>
This function allows saving data between requests in PHP session. It works only
with server that exports functions form class (see
<a href="#ref.soap.soapserver.setclass">SoapServer:setCalss</a>).
<h4>Examples</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
$server->setpersistence(SOAP_PERSISTENCE_SESSION);
$server->setpersistence(SOAP_PERSISTENCE_REQUEST);
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapserver.handle"></a>
<h2>SoapServer::handle</h2>
<p>(PHP 5)</p>
<p>handles a SOAP request</p>
<h3>Description</h3>
<p>void <b>handle</b>([string soap_envelope])</p>
It processes a SOAP request, call necessary functions, and send response back.
It assumes request in input parameter or in global <b>$HTTP_RAW_POST_DATA</b> PHP variable
if the argument is omitted.
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
function test($x) {
return $x;
}
$server = new SoapServer(null,array('uri'=>"http://test-uri/"));
$server->addFunction("test");
$server->handle();
?>
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapserver.fault"></a>
<h2>SoapServer::fault</h2>
<p>(PHP 5)</p>
<p>generates SOAP fault response</p>
<h3>Description</h3>
<p>void <b>fault</b>(string faultcode, string faultstring [, string faultactor [, mixed details]])</p>
This function is useful when you like to send SOAP fault response from PHP handler.
It never returns.
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
function test($x) {
global $server;
$server->fault("Server","Some error message");
}
$server = new SoapServer(null,array('uri'=>"http://test-uri/"));
$server->addFunction("test");
$server->handle();
?>
</PRE></TD></TR></TABLE>
<p>See also: <a href="#ref.soap.soapfault.soapfault">SoapFault::SoapFault</a></p>
<a name="ref.soap.soapparam.soapparam"></a>
<h2>SoapParam::SoapParam</h2>
<p>(PHP 5)</p>
<p>SoapParam constructor</p>
<h3>Description</h3>
<p><b>SoapParam</b>(mixed data, string name)</p>
<p>
SoapParam is a special low-level class for naming parameters and return values
in nonWSDL mode. It is just a data holder and it has not any special method
except constructor. The constructor takes <b>data</b> to pass or return and
<b>name</b>. It is possible to pass parameter directly as PHP value, but in
this case it will be named as <b><i>paramN</i></b> and SOAP Service may not
understand it.
</p>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));
$client->SomeFunction(new SoapParam($a,"a"),
new SoapParam($b,"b"),
new SoapParam($c,"c"));
?>
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapvar.soapvar"></a>
<h2>SoapVar::SoapVar</h2>
<p>(PHP 5)</p>
<p>SoapVar constructor</p>
<h3>Description</h3>
<p><b>SoapVar</b>(mixed data, int encoding [, string type [, string type_ns [, string name [, string name_ns]]]])</p>
<p>
SoapVar is a special low-level class for encoding parameters and return values
in nonWSDL mode. It is just a data holder and it has not any special method
except constructor. It is useful when you like to set type property in SOAP
request or response. The constructor takes <b>data</b> to pass or return,
<b>encoding</b> ID to encode it (see <b><i>XSD_...</i></b> constants) and as
option type name and namespace and value name and namespace.
</p>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
class SOAPStruct {
function SOAPStruct($s, $i, $f) {
$this->varString = $s;
$this->varInt = $i;
$this->varFloat = $f;
}
}
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));
$struct = new SOAPStruct('arg',34,325.325);
$soapstruct = new SoapVar($struct,SOAP_ENC_OBJECT,"SOAPStruct","http://soapinterop.org/xsd");
$client->echoStruct(new SoapParam($soapstruct, "inputStruct"));
?>
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapheader.soapheader"></a>
<h2>SoapHeader::SoapHeader</h2>
<p>(PHP 5)</p>
<p>SoapHeader constructor</p>
<h3>Description</h3>
<p><b>SoapHeader</b>(string name_ns, string name [, mixed data [, bool must_understand [, mixed actor]]])</p>
<p>
SoapHeader is a special low-level class for passing or returning SOAP headers.
It is just a data holder and it has not any special method except constructor.
It can be used in <a href="#ref.soap.soapclient.__call">SoapClient::__call</a>
method to pass SOAP header or in SOAP header handler to return header in SOAP
response. <b>name_ns</b> and <b>name</b> are namespace and name of the SOAP
header element. <b>data</b> is a SOAP header's content. It can be a PHP value
or SoapVar object. <b>must_understand</b> and <b>actor</b> are values for
<b><i>mustUnderstand</i></b> and <b><i>actor</i></b> attributes of this SOAP
Header element.
</p>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));
$client->__call("echoVoid",NULL,NULL,
new SoapHeader('http://soapinterop.org/echoheader/',
'echoMeStringRequest',
'hello world'));
?>
</PRE></TD></TR></TABLE>
<a name="ref.soap.soapfault.soapfault"></a>
<h2>SoapFault::SoapFault</h2>
<p>(PHP 5)</p>
<p>SoapFault constructor</p>
<h3>Description</h3>
<p><b>SoapFault</b>(string faultcode, string faultstring [, string faultactor [, mixed details]])</p>
This class is useful when you like to send SOAP fault response from PHP handler.
<h4>Example</h4>
<h4>Example</h4>
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
<?php
function test($x) {
return new SoapFault("Server","Some error message");
}
$server = new SoapServer(null,array('uri'=>"http://test-uri/"));
$server->addFunction("test");
$server->handle();
?>
</PRE></TD></TR></TABLE>
<p>See also: <a href="#ref.soap.soapserver.fault">SoapServer::fault</a></p>
</BODY>
</HTML>
|