3
<TITLE>PHP SOAP Manual</TITLE>
21
<TR><TD ALIGN="center"><B>Warning</B></TD></TR>
22
<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.
26
SOAP extension can be used to write SOAP Servers and Clients. It supports
27
subsets of <a href="http://www.w3.org/TR/2000/NOTE-SOAP-20000508" target="_top">SOAP 1.1</a>,
28
<a href="http://www.w3.org/TR/" target="_top">SOAP 1.2</a> and
29
<a href="http://www.w3.org/TR/wsdl" target="_top">WSDL 1.1</a> specifications.
33
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.
36
This extension is only available if PHP was configured with --enable-soap.
38
<H2>Runtime Configuration</H2>
39
<p>The behaviour of these functions is affected by settings in php.ini.</p>
41
<TR><TH>Name</TH><TH>Default</TH><TH>Changeable</TH></TR>
42
<TR><TD>soap.wsdl_cache_enabled</TD><TD>"1"</TD><TD>PHP_INI_ALL</TD></TR>
43
<TR><TD>soap.wsdl_cache_dir</TD><TD>"/tmp"</TD><TD>PHP_INI_ALL</TD></TR>
44
<TR><TD>soap.wsdl_cache_ttl</TD><TD>86400</TD><TD>PHP_INI_ALL</TD></TR>
46
</p>Here is a short explanation of the configuration directives.</p>
48
<dt><b>soap.wsdl_cache_enabled</b> (boolean)</dt>
49
<dd>enables or disables WSDL caching feature.</dd>
50
<dt><b>soap.wsdl_cache_dir</b> (string)</dt>
51
<dd>sets the directory name where SOAP extension will put cache files</dd>
52
<dt><b>soap.wsdl_cache_ttl</b> (integer)</dt>
53
<dd>(time to live) sets the number of second while cached file will be used instead of original one.</dd>
58
<H2>Predefined Constants</H2>
59
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.
61
<TR><TH>Constant</TH><TH>Value</TH><TH>Description</TH></TR>
62
<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>
63
<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>
64
<TR><TH>SOAP_FUNCTIONS_ALL (integer)</TH><TD>999</TD><TD>Allows to export all defined functions with SoapClient::addFunction</TD></TR>
65
<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>
66
<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>
67
<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>
68
<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>
69
<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>
70
<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>
71
<TR><TH>SOAP_ACTOR_NEXT (integer)</TH><TD>1</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor.</TD></TR>
72
<TR><TH>SOAP_ACTOR_NONE (integer)</TH><TD>2</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor</TD></TR>
73
<TR><TH>SOAP_ACTOR_UNLIMATERECEIVER (integer)</TH><TD>3</TD><TD>Can be passed as <b>actor</b> to SoapHeader constructor</TD></TR>
74
<TR><TH>UNKNOWN_TYPE (integer)</TH><TD>999998</TD><TD>Encoding for unknown type. Can be passed to SoapVar constructor.</TD></TR>
75
<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>
76
<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>
77
<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>
78
<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>
79
<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>
80
<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>
81
<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>
82
<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>
83
<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>
84
<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>
85
<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>
86
<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>
87
<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>
88
<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>
89
<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>
90
<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>
91
<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>
92
<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>
93
<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>
94
<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>
95
<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>
96
<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>
97
<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>
98
<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>
99
<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>
100
<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>
101
<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>
102
<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>
103
<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>
104
<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>
105
<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>
106
<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>
107
<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>
108
<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>
109
<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>
110
<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>
111
<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>
112
<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>
113
<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>
114
<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>
115
<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>
116
<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>
117
<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>
118
<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>
119
<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>
120
<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>
121
<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>
122
<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>
123
<TR><TH>XSD_NAMESPACE (string)</TH><TD> </TD><TD>The XML Schema namespace.</TD></TR>
124
<TR><TH>XSD_1999_NAMESPACE (string)</TH><TD> </TD><TD>The old XML Schema namespace.</TD></TR>
128
<h4>List of classes</h4>
130
<tr><td><a href="#ref.soap.soapclient">SoapClient</a></td></tr>
131
<tr><td><a href="#ref.soap.soapserver">SoapServer</a></td></tr>
132
<tr><td><a href="#ref.soap.soapparam">SoapParam</a></td></tr>
133
<tr><td><a href="#ref.soap.soapvar">SoapVar</a></td></tr>
134
<tr><td><a href="#ref.soap.soapheader">SoapHeader</a></td></tr>
135
<tr><td><a href="#ref.soap.soapfault">SoapFault</a></td></tr>
137
<a name="ref.soap.soapclient">
138
<h4>SoapClient class</h4>
139
A SOAP client, that allows calling remote methods on SOAP WebService over HTTP
142
<tr><td><a href="#ref.soap.soapclient.soapclient">SoapClient</a> -- SoapClient constructor</td></tr>
143
<tr><td><a href="#ref.soap.soapclient.__call">__call</a> -- calls a SOAP function</td></tr>
144
<tr><td><a href="#ref.soap.soapclient.__getlastrequest">__getLastRequest</a> -- returns last SOAP request</td></tr>
145
<tr><td><a href="#ref.soap.soapclient.__getlastresponse">__getLastResponse</a> -- returns last SOAP response</td></tr>
146
<tr><td><a href="#ref.soap.soapclient.__getfunctions">__getFunctions</a> -- returns list of SOAP functions</td></tr>
147
<tr><td><a href="#ref.soap.soapclient.__gettypes">__getTypes</a> -- returns list of SOAP types</td></tr>
149
<a name="ref.soap.soapserver">
150
<h4>SoapServer class</h4>
151
This class can be used to build SOAP WebServices, which can be accessed from
152
remote SOAP clients over HTTP or HTTPS.
154
<tr><td><a href="#ref.soap.soapserver.soapserver">SoapServer</a> -- SoapServer constructor</td></tr>
155
<tr><td><a href="#ref.soap.soapserver.addfunction">addFunction</a> -- adds one or several functions those will handle SOAP requests</td></tr>
156
<tr><td><a href="#ref.soap.soapserver.setclass">setClass</a> -- sets class which will handle SOAP requests</td></tr>
157
<tr><td><a href="#ref.soap.soapserver.getfunctions">getFunctions</a> -- returns list of defined functions</td></tr>
158
<tr><td><a href="#ref.soap.soapserver.setpersistence">setPersistence</a> -- sets persistence mode of SoapServer</td></tr>
159
<tr><td><a href="#ref.soap.soapserver.handle">handle</a> -- handles a SOAP request</td></tr>
161
<a name="ref.soap.soapparam">
162
<h4>SoapParam class</h4>
164
SoapParam is a special low-level class for naming parameters and return values
165
in nonWSDL mode. It is just a data holder and it has not any special method
169
<tr><td><a href="#ref.soap.soapparam.soapparam">SoapParam</a> -- SoapParam constructor</td></tr>
171
<a name="ref.soap.soapvar">
172
<h4>SoapVar classes</h4>
174
SoapVar is a special low-level class for encoding parameters and return values
175
in nonWSDL mode. It is just a data holder and it has not any special method
176
except constructor. It is useful when you like to set type property in SOAP
180
<tr><td><a href="#ref.soap.soapvar.soapvar">SoapVar</a> -- SoapVar constructor</td></tr>
182
<a name="ref.soap.soapheader">
183
<h4>SoapHeader class</h4>
185
SoapHeader is a special low-level class for passing or returning SOAP headers.
186
It is just a data holder and it has not any special method except constructor.
189
<tr><td><a href="#ref.soap.soapheader.soapheader">SoapHeader</a> -- SoapHeader constructor</td></tr>
191
<a name="ref.soap.soapfault">
192
<h4>SoapFault class</h4>
194
SoapFault is a special class that can be used for error reporting during
195
handling of SOAP request. It is derived form standard PHP Exception class,
196
so it can be used to throw exceptions in server side and to catch tham on
200
<tr><td><a href="#ref.soap.soapfault.soapfault">SoapFault</a> -- SoapFault constructor</td></tr>
206
<h4>Table of Contents</h4>
208
<tr><td><a href="#ref.soap.is_soap_fault">is_soap_fault</a> -- checks if SOAP call was failed</td></tr>
209
<tr><td><a href="#ref.soap.soapclient.soapclient">SoapClient::SoapClient</a> -- SoapClient constructor</td></tr>
210
<tr><td><a href="#ref.soap.soapclient.__call">SoapClient::__call</a> -- calls a SOAP function</td></tr>
211
<tr><td><a href="#ref.soap.soapclient.__getlastrequest">SoapClient::__getLastRequest</a> -- returns last SOAP request</td></tr>
212
<tr><td><a href="#ref.soap.soapclient.__getlastresponse">SoapClient::__getLastResponse</a> -- returns last SOAP response</td></tr>
213
<tr><td><a href="#ref.soap.soapclient.__getfunctions">SoapClient::__getFunctions</a> -- returns list of SOAP functions</td></tr>
214
<tr><td><a href="#ref.soap.soapclient.__gettypes">SoapClient::__getTypes</a> -- returns list of SOAP types</td></tr>
215
<tr><td><a href="#ref.soap.soapserver.soapserver">SoapServer::SoapServer</a> -- SoapServer constructor</td></tr>
216
<tr><td><a href="#ref.soap.soapserver.addfunction">SoapServer::addFunction</a> -- adds one or several functions those will handle SOAP requests</td></tr>
217
<tr><td><a href="#ref.soap.soapserver.setclass">SoapServer::setClass</a> -- sets class which will handle SOAP requests</td></tr>
218
<tr><td><a href="#ref.soap.soapserver.getfunctions">SoapServer::getFunctions</a> -- returns list of defined functions</td></tr>
219
<tr><td><a href="#ref.soap.soapserver.setpersistence">SoapServer::setPersistence</a> -- sets persistence mode of SoapServer</td></tr>
220
<tr><td><a href="#ref.soap.soapserver.handle">SoapServer::handle</a> -- handles a SOAP request</td></tr>
221
<tr><td><a href="#ref.soap.soapparam.soapparam">SoapParam::SoapParam</a> -- SoapParam constructor</td></tr>
222
<tr><td><a href="#ref.soap.soapvar.soapvar">SoapVar::SoapVar</a> -- SoapVar constructor</td></tr>
223
<tr><td><a href="#ref.soap.soapheader.soapheader">SoapHeader::SoapHeader</a> -- SoapHeader constructor</td></tr>
224
<tr><td><a href="#ref.soap.soapfault.soapfault">SoapFault::SoapFault</a> -- SoapFault constructor</td></tr>
227
<a name="ref.soap.is_soap_fault"></a>
228
<h2>is_soap_fault</h2>
230
<p>checks if SOAP call was failed</p>
232
<p>bool <b>is_soap_fault</b>(mixed obj)</p>
234
This function is useful when you like to check if the SOAP call was failed,
235
but don't like to use exceptions. To use it you must create SoapClient object
236
with <b>exceptions</b> option set to zero or false. In this case SOAP method
237
will return a special SoapFault object which encapsulate the fault details
238
(faultcode, faultstring, faultactor and faultdetails). If <b>exceptions</b> is
239
not set then SOAP call will throw an exception on error.<br>
240
is_soap_fault() functions checks if the given parameter is a SoapFault object.<br>
243
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
245
$client = SoapClient("some.wsdl",array("exceptions"=>0));
246
$result = $client->SomeFunction(...);
247
if (is_soap_fault($result)) {
248
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faulstring})", E_ERROR);
250
?></PRE></TD></TR></TABLE>
251
<p>Standard method that used by SOAP extension for error reporting is excptions.</p>
252
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
255
$client = SoapClient("some.wsdl");
256
$result = $client->SomeFunction(...);
257
} catch (SoapFault $fault) {
258
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faulstring})", E_ERROR);
260
?></PRE></TD></TR></TABLE>
262
<a name="ref.soap.soapclient.soapclient"></a>
263
<h2>SoapClient::SoapClient</h2>
265
<p>SoapClient constructor</p>
267
<p><b>SoapClient</b>(mixed wsdl [, array options])</p>
269
The constructor allows creating SoapClient objects in WSDL or nonWSDL mode.
270
The first case requires URI of WSDL file as first parameter and optional
271
options array. The second case requires NULL as first parameter and options
272
array with <b>location</b> and <b>uri</b> options set. Where <b>location</b> is
273
a URL to request and <b>uri</b> is a target namespace of the SOAP service.
274
<b>style</b> and <b>use</b> options has effect only on nonWSDL (in WSDL mode
275
they comes from WSDL file). <b>soap_version</b> option allows to work as SOAP 1.1 or
277
Some additional optional options allow using HTTP authentication (<b>login</b>
278
and <b>password</b>) and HTTP connection through proxy server (<b>proxy_host</b>,
279
<b>proxy_port</b>, <b>proxy_login</b> and <b>proxy_password</b>).
282
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
283
$client = new SoapClient("some.wsdl");
285
$client = new SoapClient("some.wsdl",array('soap_version' => SOAP_1_2));
287
$client = new SoapClient("some.wsdl",array('login' => "some_name",
288
'password' => "some_password"));
290
$client = new SoapClient("some.wsdl",array('proxy_host' => "localhost",
291
'proxy_port' => 8080));
293
$client = new SoapClient("some.wsdl",array('proxy_host' => "localhost",
294
'proxy_port' => 8080,
295
'proxy_login' => "some_name",
296
'proxy_password' => "some_password"));
298
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
299
'uri' => "http://test-uri/"));
301
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
302
'uri' => "http://test-uri/",
303
'style' => SOAP_DOCUMENT,
304
'use' => SOAP_LITERAL));
305
</PRE></TD></TR></TABLE>
307
<a name="ref.soap.soapclient.__call"></a>
308
<h2>SoapClient::__call</h2>
310
<p>calls a SOAP function</p>
312
<p>mixed <b>__call</b>(string function_name, array arguments, [array options [, mixed input_headers [, mixed &output_headers]]])</p>
314
This is a low level API function to make a SOAP call. Usually in WSDL mode
315
you can simple call SOAP functions as SoapClient methods. It is useful for
316
nonWSDL mode when 'soapaction' is unknown, 'uri' is differ form default or
317
when ypu like to send and/or receive SOAP Headers. To check if function call
318
is failed check the result with is_soap_fault() function.<br>
319
SOAP function may return one or several values. In the first case __call will
320
return just the value of output parameter, in the second it will return
321
array with named output parameters.
324
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
325
$client = new SoapClient("some.wsdl");
326
$client->SomeFunction($a,$b,$c);
327
$client->__call("SomeFunction",array($a,$b,$c));
328
$client->__call("SomeFunction",array($a,$b,$c), NULL,
329
new SoapHeader(...), $output_headers);
332
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
333
'uri' => "http://test-uri/"));
334
$client->SomeFunction($a,$b,$c);
335
$client->__call("SomeFunction",array($a,$b,$c));
336
$client->__call("SomeFunction",array($a,$b,$c),
337
array('soapaction' => 'some_action',
338
'uri' => 'some_uri'));
339
</PRE></TD></TR></TABLE>
341
<a name="ref.soap.soapclient.__getlastrequest"></a>
342
<h2>SoapClient::__getLastRequest</h2>
344
<p>returns last SOAP request</p>
346
<p>string <b>__getLastRequest</b>()</p>
348
This function works only with SoapClient which was created with trace option.
351
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
353
$client = SoapClient("some.wsdl", array('trace'=>1));
354
$result = $client->SomeFunction(...);
355
echo "REQUEST:\n".$client->__getLastRequest()."\n";
357
</PRE></TD></TR></TABLE>
359
<a name="ref.soap.soapclient.__getlastresponse"></a>
360
<h2>SoapClient::__getLastResponse</h2>
362
<p>returns last SOAP response</p>
364
<p>string <b>__getLastResponse</b>()</p>
366
This function works only with SoapClient which was created with trace option.
369
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
371
$client = SoapClient("some.wsdl", array('trace'=>1));
372
$result = $client->SomeFunction(...);
373
echo "RESPONSE:\n".$client->__getLastResponse()."\n";
375
</PRE></TD></TR></TABLE>
377
<a name="ref.soap.soapclient.__getfunctions"></a>
378
<h2>SoapClient::__getFunctions</h2>
380
<p>returns list of SOAP functions</p>
382
<p>array <b>__getFunctions</b>()</p>
384
This function works only in WSDL mode.
387
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
389
$client = SoapClient("some.wsdl");
390
var_dump($client->__getFunctions());
392
</PRE></TD></TR></TABLE>
394
<a name="ref.soap.soapclient.__gettypes"></a>
395
<h2>SoapClient::__getTypes</h2>
397
<p>returns list of SOAP types</p>
399
<p>array <b>__getTypes</b>()</p>
401
This function works only in WSDL mode.
404
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
406
$client = SoapClient("some.wsdl");
407
var_dump($client->__getTypes());
409
</PRE></TD></TR></TABLE>
411
<a name="ref.soap.soapserver.soapserver"></a>
412
<h2>SoapServer::SoapServer</h2>
414
<p>SoapServer constructor</p>
416
<p><b>SoapServer</b>(mixed wsdl [, array options])</p>
417
It allows creating SoapServer objects in WSDL or nonWSDL mode. In the first
418
case <b>wsdl</b> must be set to URI of WSDL file. In the second <b>wsdl</b>
419
must be set to null and <b>uti</b> option must be set. Additional options
420
allow setting a default SOAP version (<b>soap_version</b>) and actor URI
424
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
425
$server = new SoapServer("some.wsdl");
427
$server = new SoapServer("some.wsdl",array('soap_version'=>SOAP_1_2));
429
$server = new SoapServer("some.wsdl",array('actor'=>"http://example.org/ts-tests/C"));
431
$server = new SoapServer(null,array('uri'=>"http://test-uri/"));
432
</PRE></TD></TR></TABLE>
434
<a name="ref.soap.soapserver.addfunction">
435
<h2>SoapServer::addFunction</h2>
437
<p>adds one or several functions those will handle SOAP requests</p>
439
<p>void <b>addFunction</b>(mixed functions)</p>
440
Exports one or more functions for remote clients. To export one function pass
441
function name into <b>functions</b> parameter as string. To export several
442
functions pass an array of function names and to export all functions pass
443
a special constant <b>SOAP_FUNCTIONS_ALL</b>.<br>
444
Functions must receive all input arguments in the same order as defined
445
in WSDL file (They should not receive any output parameters as arguments) and
446
return one or more values. To return several values they must return array with
447
named output parameters.
449
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
450
function func($inputString) {
453
$server->addFunction("echoString");
455
function echoTwoStrings($inputString1, $inputString2) {
456
return array("outputString1"=>$inputString1,"outputString2"=>$inputString2);
458
$server->addFunction(array("echoString","echoTwoStrings"));
460
$server->addFunction(SOAP_FUNCTIONS_ALL);
461
</PRE></TD></TR></TABLE>
463
<a name="ref.soap.soapserver.setclass"></a>
464
<h2>SoapServer::setClass</h2>
466
<p>sets class which will handle SOAP requests</p>
468
<p>void <b>setClass</b>(string class_name [, ...])</p>
469
Exports all methods from specified class. Additional parameters will be passed
470
to default class constructor during object creation. The object can be maiden
471
persistent across request for a given PHP session with
472
<a href="#ref.soap.soapserver.setpersistence">SoapServer::setPersistence</a> method.
474
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
475
$server->setClass("foo");
477
$server->setClass("foo", $arg1, $arg2);
478
</PRE></TD></TR></TABLE>
480
<a name="ref.soap.soapserver.getfunctions">
481
<h2>SoapServer::getFunctions</h2>
483
<p>returns list of defined functions</p>
485
<p>array <b>getFunctions</b>()</p>
487
<a name="ref.soap.soapserver.setpersistence"></a>
488
<h2>SoapServer::setPersistence</h2>
490
<p>sets persistence mode of SoapServer</p>
492
<p>void <b>setPersistence</b>(int mode)</p>
493
This function allows saving data between requests in PHP session. It works only
494
with server that exports functions form class (see
495
<a href="#ref.soap.soapserver.setclass">SoapServer:setCalss</a>).
497
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
498
$server->setpersistence(SOAP_PERSISTENCE_SESSION);
500
$server->setpersistence(SOAP_PERSISTENCE_REQUEST);
501
</PRE></TD></TR></TABLE>
503
<a name="ref.soap.soapserver.handle"></a>
504
<h2>SoapServer::handle</h2>
506
<p>handles a SOAP request</p>
508
<p>void <b>handle</b>([string soap_envelope])</p>
509
It processes a SOAP request, call necessary functions, and send response back.
510
It assumes request in input parameter or in global <b>$HTTP_RAW_POST_DATA</b> PHP variable
511
if the argument is omitted.
513
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
519
$server = new SoapServer(null,array('uri'=>"http://test-uri/"));
520
$server->addFunction("test");
523
</PRE></TD></TR></TABLE>
525
<a name="ref.soap.soapparam.soapparam"></a>
526
<h2>SoapParam::SoapParam</h2>
528
<p>SoapParam constructor</p>
530
<p><b>SoapParam</b>(mixed data, string name)</p>
532
SoapParam is a special low-level class for naming parameters and return values
533
in nonWSDL mode. It is just a data holder and it has not any special method
534
except constructor. The constructor takes <b>data</b> to pass or return and
535
<b>name</b>. It is possible to pass parameter directly as PHP value, but in
536
this case it will be named as <b><i>paramN</i></b> and SOAP Service may not
540
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
542
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
543
'uri' => "http://test-uri/"));
544
$client->SomeFunction(new SoapParam($a,"a"),
545
new SoapParam($b,"b"),
546
new SoapParam($c,"c"));
548
</PRE></TD></TR></TABLE>
550
<a name="ref.soap.soapvar.soapvar"></a>
551
<h2>SoapVar::SoapVar</h2>
553
<p>SoapVar constructor</p>
555
<p><b>SoapVar</b>(mixed data, int encoding [, string type [, string type_ns [, string name [, string name_ns]]]])</p>
557
SoapVar is a special low-level class for encoding parameters and return values
558
in nonWSDL mode. It is just a data holder and it has not any special method
559
except constructor. It is useful when you like to set type property in SOAP
560
request or response. The constructor takes <b>data</b> to pass or return,
561
<b>encoding</b> ID to encode it (see <b><i>XSD_...</i></b> constants) and as
562
option type name and namespace and value name and namespace.
565
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
568
function SOAPStruct($s, $i, $f) {
569
$this->varString = $s;
571
$this->varFloat = $f;
574
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
575
'uri' => "http://test-uri/"));
576
$struct = new SOAPStruct('arg',34,325.325);
577
$soapstruct = new SoapVar($struct,SOAP_ENC_OBJECT,"SOAPStruct","http://soapinterop.org/xsd");
578
$client->echoStruct(new SoapParam($soapstruct, "inputStruct"));
580
</PRE></TD></TR></TABLE>
582
<a name="ref.soap.soapheader.soapheader"></a>
583
<h2>SoapHeader::SoapHeader</h2>
585
<p>SoapHeader constructor</p>
587
<p><b>SoapHeader</b>(string name_ns, string name [, mixed data [, bool must_understand [, mixed actor]]])</p>
589
SoapHeader is a special low-level class for passing or returning SOAP headers.
590
It is just a data holder and it has not any special method except constructor.
591
It can be used in <a href="#ref.soap.soapclient.__call">SoapClient::__call</a>
592
method to pass SOAP header or in SOAP header handler to return header in SOAP
593
response. <b>name_ns</b> and <b>name</b> are namespace and name of the SOAP
594
header element. <b>data</b> is a SOAP header's content. It can be a PHP value
595
or SoapVar object. <b>must_understand</b> and <b>actor</b> are values for
596
<b><i>mustUnderstand</i></b> and <b><i>actor</i></b> attributes of this SOAP
600
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
602
$client = new SoapClient(null,array('location' => "http://localhost/soap.php",
603
'uri' => "http://test-uri/"));
604
$client->__call("echoVoid",NULL,NULL,
605
new SoapHeader('http://soapinterop.org/echoheader/',
606
'echoMeStringRequest',
609
</PRE></TD></TR></TABLE>
611
<a name="ref.soap.soapfault.soapfault"></a>
612
<h2>SoapFault::SoapFault</h2>
614
<p>SoapFault constructor</p>
616
<p><b>SoapFault</b>(string faultcode, string faultstring [, string faultactor [, mixed details [, string faultname [, mixed headerfault]]]])</p>
617
This class is useful when you like to send SOAP fault response from PHP handler.<br>
618
<b>faultcode</b>, <b>faultstring</b>, <b>faultactor</b> and <b>details</b> are standard elements of SOAP Fault;<br>
619
<b>faultname</b> is an optional parameter that can be used to select proper fault encoding from WSDL.<br>
620
<b>headerfault</b> is an optional parameter that can be used during SOAP header handling to report error in response header.
622
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
625
return new SoapFault("Server","Some error message");
628
$server = new SoapServer(null,array('uri'=>"http://test-uri/"));
629
$server->addFunction("test");
632
</PRE></TD></TR></TABLE>
633
<p>It is possible to use PHP exception mechanism to throw SOAP Fault.</p>
634
<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php">
637
throw new SoapFault("Server","Some error message");
640
$server = new SoapServer(null,array('uri'=>"http://test-uri/"));
641
$server->addFunction("test");
644
</PRE></TD></TR></TABLE>
b'\\ No newline at end of file'