diff --git a/reference/soap/constants.xml b/reference/soap/constants.xml index 36060d272162..baf9f2868f90 100644 --- a/reference/soap/constants.xml +++ b/reference/soap/constants.xml @@ -21,7 +21,11 @@ (<type>int</type>) </entry> <entry>1</entry> - <entry></entry> + <entry> + Specifies use of SOAP 1.1 when passed as <literal>soap_version</literal> + option to <methodname>SoapServer::__construct</methodname> or + <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-1-2"> <entry> @@ -29,7 +33,11 @@ (<type>int</type>) </entry> <entry>2</entry> - <entry></entry> + <entry> + Specifies use of SOAP 1.2 when passed as <literal>soap_version</literal> + option to <methodname>SoapServer::__construct</methodname> or + <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-persistence-session"> <entry> @@ -61,7 +69,10 @@ (<type>int</type>) </entry> <entry>1</entry> - <entry></entry> + <entry> + Specifies use of SOAP Encoding when passed as <literal>use</literal> + option to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-literal"> <entry> @@ -69,7 +80,10 @@ (<type>int</type>) </entry> <entry>2</entry> - <entry></entry> + <entry> + Specifies use of service-specific encoding when passed as <literal>use</literal> + option to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-rpc"> <entry> @@ -77,7 +91,10 @@ (<type>int</type>) </entry> <entry>1</entry> - <entry></entry> + <entry> + Specifies use of RPC-style binding when passed as <literal>style</literal> + option to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-document"> <entry> @@ -85,7 +102,10 @@ (<type>int</type>) </entry> <entry>2</entry> - <entry></entry> + <entry> + Specifies use of document binding when passed as <literal>style</literal> + option to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-actor-next"> <entry> @@ -117,7 +137,13 @@ (<type>int</type>) </entry> <entry>32</entry> - <entry></entry> + <entry> + Specifies use of an "Accept-Encoding" header + when passed as part of + <link linkend="soapclient.construct.options.compression"> + the <parameter>compression</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-compression-gzip"> <entry> @@ -125,7 +151,13 @@ (<type>int</type>) </entry> <entry>0</entry> - <entry></entry> + <entry> + Specifies use of gzip compression + when passed as part of + <link linkend="soapclient.construct.options.compression"> + the <parameter>compression</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-compression-deflate"> <entry> @@ -133,7 +165,13 @@ (<type>int</type>) </entry> <entry>16</entry> - <entry></entry> + <entry> + Specifies use of deflate compression + when passed as part of + <link linkend="soapclient.construct.options.compression"> + the <parameter>compression</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-authentication-basic"> <entry> @@ -141,7 +179,11 @@ (<type>int</type>) </entry> <entry>0</entry> - <entry></entry> + <entry> + Specifies use of HTTP Basic Authentication when passed as + <literal>authentication</literal> option to + <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-authentication-digest"> <entry> @@ -149,7 +191,11 @@ (<type>int</type>) </entry> <entry>1</entry> - <entry></entry> + <entry> + Specifies use of HTTP Digest Authentication when passed as + <literal>authentication</literal> option to + <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-ssl-method-tls"> <entry> @@ -157,7 +203,12 @@ (<type>int</type>) </entry> <entry>0</entry> - <entry></entry> + <entry> + Used with the deprecated + <link linkend="soapclient.construct.options.ssl-method"> + <parameter>ssl_method</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-ssl-method-sslv2"> <entry> @@ -165,7 +216,12 @@ (<type>int</type>) </entry> <entry>1</entry> - <entry></entry> + <entry> + Used with the deprecated + <link linkend="soapclient.construct.options.ssl-method"> + <parameter>ssl_method</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-ssl-method-sslv3"> <entry> @@ -173,7 +229,12 @@ (<type>int</type>) </entry> <entry>2</entry> - <entry></entry> + <entry> + Used with the deprecated + <link linkend="soapclient.construct.options.ssl-method"> + <parameter>ssl_method</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-ssl-method-sslv23"> <entry> @@ -181,7 +242,12 @@ (<type>int</type>) </entry> <entry>3</entry> - <entry></entry> + <entry> + Used with the deprecated + <link linkend="soapclient.construct.options.ssl-method"> + <parameter>ssl_method</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.unknown-type"> <entry> @@ -613,7 +679,12 @@ (<type>int</type>) </entry> <entry>1</entry> - <entry></entry> + <entry> + Used with the + <link linkend="soapclient.construct.options.features"> + <parameter>features</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-wait-one-way-calls"> <entry> @@ -621,7 +692,12 @@ (<type>int</type>) </entry> <entry>2</entry> - <entry></entry> + <entry> + Used with the + <link linkend="soapclient.construct.options.features"> + <parameter>features</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.soap-use-xsi-array-type"> <entry> @@ -629,7 +705,12 @@ (<type>int</type>) </entry> <entry>4</entry> - <entry></entry> + <entry> + Used with the + <link linkend="soapclient.construct.options.features"> + <parameter>features</parameter> option</link> + to <methodname>SoapClient::__construct</methodname>. + </entry> </row> <row xml:id="constant.wsdl-cache-none"> <entry> @@ -637,7 +718,14 @@ (<type>int</type>) </entry> <entry>0</entry> - <entry></entry> + <entry> + Disables the WSDL cache when used in the + <link linkend="ini.soap.wsdl-cache">soap.wsdl_cache</link> + configuration option or the + <literal>wsdl_cache</literal> option + to <methodname>SoapClient::__construct</methodname> + and <methodname>SoapServer::__construct</methodname>. + </entry> </row> <row xml:id="constant.wsdl-cache-disk"> <entry> @@ -645,7 +733,14 @@ (<type>int</type>) </entry> <entry>1</entry> - <entry></entry> + <entry> + Specifies use of the on-disk WSDL cache only when used in the + <link linkend="ini.soap.wsdl-cache">soap.wsdl_cache</link> + configuration option or the + <literal>wsdl_cache</literal> option + to <methodname>SoapClient::__construct</methodname> + and <methodname>SoapServer::__construct</methodname>. + </entry> </row> <row xml:id="constant.wsdl-cache-memory"> <entry> @@ -653,7 +748,14 @@ (<type>int</type>) </entry> <entry>2</entry> - <entry></entry> + <entry> + Specifies use of the in-memory WSDL cache only when used in the + <link linkend="ini.soap.wsdl-cache">soap.wsdl_cache</link> + configuration option or the + <literal>wsdl_cache</literal> option + to <methodname>SoapClient::__construct</methodname> + and <methodname>SoapServer::__construct</methodname>. + </entry> </row> <row xml:id="constant.wsdl-cache-both"> <entry> @@ -661,7 +763,14 @@ (<type>int</type>) </entry> <entry>3</entry> - <entry></entry> + <entry> + Specifies use of both on-disk and in-memory WSDL caches when used in the + <link linkend="ini.soap.wsdl-cache">soap.wsdl_cache</link> + configuration option or the + <literal>wsdl_cache</literal> option + to <methodname>SoapClient::__construct</methodname> + and <methodname>SoapServer::__construct</methodname>. + </entry> </row> </tbody> </tgroup> diff --git a/reference/soap/soapclient/construct.xml b/reference/soap/soapclient/construct.xml index 4b56a8148d63..80e5d46997e0 100644 --- a/reference/soap/soapclient/construct.xml +++ b/reference/soap/soapclient/construct.xml @@ -14,8 +14,7 @@ <methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam> </constructorsynopsis> <para> - This constructor creates <classname>SoapClient</classname> objects - in <literal>WSDL</literal> or <literal>non-WSDL</literal> mode. + Creates a <classname>SoapClient</classname> object to connect to a SOAP service. </para> </refsect1> @@ -27,15 +26,17 @@ <term><parameter>wsdl</parameter></term> <listitem> <para> - URI of the <literal>WSDL</literal> file or &null; if working in - <literal>non-WSDL</literal> mode. + URI of a WSDL file describing the service, which is used to automatically + configure the client. If not provided, the client will operate in non-WSDL + mode. </para> <note> <para> - During development, WSDL caching may be disabled by the - use of the <literal>soap.wsdl_cache_ttl</literal> &php.ini; setting - otherwise changes made to the WSDL file will have no effect until - <literal>soap.wsdl_cache_ttl</literal> is expired. + By default, the WSDL file will be cached for performance. To disable + or configure this caching, see + <link linkend="soap.configuration.list">SOAP &ConfigureOptions;</link> + and the <link linkend="soapclient.construct.options.cache-wsdl"> + <literal>cache_wsdl</literal> option</link>. </para> </note> </listitem> @@ -44,116 +45,583 @@ <term><parameter>options</parameter></term> <listitem> <para> - An array of options. If working in WSDL mode, this parameter is optional. - If working in non-WSDL mode, the <literal>location</literal> and - <literal>uri</literal> options must be set, where <literal>location</literal> - is the URL of the SOAP server to send the request to, and <literal>uri</literal> - is the target namespace of the SOAP service. - </para> - <para> - The <literal>style</literal> and <literal>use</literal> options only work in - non-WSDL mode. In WSDL mode, they come from the WSDL file. - </para> - <para> - The <literal>soap_version</literal> option should be one of either - <constant>SOAP_1_1</constant> or <constant>SOAP_1_2</constant> to - select SOAP 1.1 or 1.2, respectively. If omitted, 1.1 is used. - </para> - <para> - For HTTP authentication, the <literal>login</literal> and - <literal>password</literal> options can be used to supply credentials. - For making an HTTP connection through - a proxy server, the options <literal>proxy_host</literal>, - <literal>proxy_port</literal>, <literal>proxy_login</literal> - and <literal>proxy_password</literal> are also available. - For HTTPS client certificate authentication use - <literal>local_cert</literal> and <literal>passphrase</literal> options. An - authentication may be supplied in the <literal>authentication</literal> - option. The authentication method may be either - <constant>SOAP_AUTHENTICATION_BASIC</constant> (default) or - <constant>SOAP_AUTHENTICATION_DIGEST</constant>. - </para> - <para> - The <literal>compression</literal> option allows to use compression - of HTTP SOAP requests and responses. - </para> - <para> - The <literal>encoding</literal> option defines internal character - encoding. This option does not change the encoding of SOAP requests (it is - always utf-8), but converts strings into it. - </para> - <para> - The <literal>trace</literal> option enables tracing of request so faults - can be backtraced. This defaults to &false; - </para> - <para> - The <literal>classmap</literal> option can be used to map some WSDL - types to PHP classes. This option must be an array with WSDL types - as keys and names of PHP classes as values. - </para> - <para> - Setting the boolean <literal>trace</literal> option enables use of the - methods <link linkend="soapclient.getlastrequest"> - SoapClient->__getLastRequest</link>, - <link linkend="soapclient.getlastrequestheaders"> - SoapClient->__getLastRequestHeaders</link>, - <link linkend="soapclient.getlastresponse"> - SoapClient->__getLastResponse</link> and - <link linkend="soapclient.getlastresponseheaders"> - SoapClient->__getLastResponseHeaders</link>. - </para> - <para> - The <literal>exceptions</literal> option is a boolean value defining whether - soap errors throw exceptions of type <link - linkend="soapfault.construct"> - SoapFault</link>. - </para> - <para> - The <literal>connection_timeout</literal> option defines a timeout in seconds - for the connection to the SOAP service. This option does not define a timeout - for services with slow responses. To limit the time to wait for calls to finish the - <link linkend="ini.default-socket-timeout">default_socket_timeout</link> setting - is available. - </para> - <para> - The <literal>typemap</literal> option is an array of type mappings. - Type mapping is an array with keys <literal>type_name</literal>, - <literal>type_ns</literal> (namespace URI), <literal>from_xml</literal> - (callback accepting one string parameter) and <literal>to_xml</literal> - (callback accepting one object parameter). - </para> - <para> - The <literal>cache_wsdl</literal> option is one of - <constant>WSDL_CACHE_NONE</constant>, - <constant>WSDL_CACHE_DISK</constant>, - <constant>WSDL_CACHE_MEMORY</constant> or - <constant>WSDL_CACHE_BOTH</constant>. - </para> - <para> - The <literal>user_agent</literal> option specifies string to use in - <literal>User-Agent</literal> header. - </para> - <para> - The <literal>stream_context</literal> option is a <type>resource</type> - for <link linkend="context">context</link>. - </para> - <para> - The <literal>features</literal> option is a bitmask of - <constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant>, - <constant>SOAP_USE_XSI_ARRAY_TYPE</constant>, - <constant>SOAP_WAIT_ONE_WAY_CALLS</constant>. - </para> - <para> - The <literal>keep_alive</literal> option is a boolean value defining whether - to send the <literal>Connection: Keep-Alive</literal> header or - <literal>Connection: close</literal>. - </para> - <para> - The <literal>ssl_method</literal> option is one of - <constant>SOAP_SSL_METHOD_TLS</constant>, - <constant>SOAP_SSL_METHOD_SSLv2</constant>, - <constant>SOAP_SSL_METHOD_SSLv3</constant> or - <constant>SOAP_SSL_METHOD_SSLv23</constant>. + An associative array specifying additional options for the SOAP client. + If <parameter>wsdl</parameter> is provided, this is optional; otherwise, + at least <literal>location</literal> and <literal>url</literal> must be + provided. + <variablelist> + <varlistentry xml:id="soapclient.construct.options.location"> + <term> + <parameter>location</parameter> + <type>string</type> + </term> + <listitem> + <para> + The URL of the SOAP server to send the request to. + </para> + <para> + Required if the <parameter>wsdl</parameter> parameter is not provided. + If both a <parameter>wsdl</parameter> parameter and + <literal>location</literal> option are provided, the + <literal>location</literal> option will over-ride any location + specified in the WSDL file. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.uri"> + <term> + <parameter>uri</parameter> + <type>string</type> + </term> + <listitem> + <para> + The target namespace of the SOAP service. + </para> + <para> + Required if the <parameter>wsdl</parameter> parameter is not provided; + ignored otherwise. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.style"> + <term> + <parameter>style</parameter> + <type>int</type> + </term> + <listitem> + <para> + Specifies the binding style to use for this client, using the constants + <constant>SOAP_RPC</constant> and <constant>SOAP_DOCUMENT</constant>. + <constant>SOAP_RPC</constant> indicates RPC-style binding, where the + SOAP request body contains a standard encoding of a function call. + <constant>SOAP_DOCUMENT</constant> indicates document-style binding, + where the SOAP request body contains an XML document with + service-defined meaning. + </para> + <para> + If the <parameter>wsdl</parameter> parameter is provided, this + option is ignored, and the style is read from the WSDL file. + </para> + <para> + If neither this option nor the <parameter>wsdl</parameter> parameter + is provided, RPC-style is used. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.use"> + <term> + <parameter>use</parameter> + <type>int</type> + </term> + <listitem> + <para> + Specifies the encoding style to use for this client, using the + constants <constant>SOAP_ENCODED</constant> or <constant>SOAP_LITERAL</constant>. + <constant>SOAP_ENCODED</constant> indicates encoding using the types + defined in the SOAP specification. + <constant>SOAP_LITERAL</constant> indicates encoding using a schema + defined by the service. + </para> + <para> + If the <parameter>wsdl</parameter> parameter is provided, this + option is ignored, and the encoding is read from the WSDL file. + </para> + <para> + If neither this option nor the <parameter>wsdl</parameter> parameter + is provided, the "encoded" style is used. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.soap-version"> + <term> + <parameter>soap_version</parameter> + <type>int</type> + </term> + <listitem> + <para> + Specifies the version of the SOAP protocol to use: + <constant>SOAP_1_1</constant> for SOAP 1.1, + or <constant>SOAP_1_2</constant> for SOAP 1.2. + </para> + <para> + If omitted, SOAP 1.1 is used. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.authentication"> + <term> + <parameter>authentication</parameter> + <type>int</type> + </term> + <listitem> + <para> + Specifies the authentication method when using HTTP authentication + in requests. The value may be either + <constant>SOAP_AUTHENTICATION_BASIC</constant> + or <constant>SOAP_AUTHENTICATION_DIGEST</constant>. + </para> + <para> + If omitted, and the <literal>login</literal> option is provided, + Basic Authentication is used. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.login"> + <term> + <parameter>login</parameter> + <type>string</type> + </term> + <listitem> + <para> + Username to use with HTTP Basic or Digest Authentication. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.password"> + <term> + <parameter>password</parameter> + <type>string</type> + </term> + <listitem> + <para> + Password to use with HTTP Basic or Digest Authentication. + </para> + <para> + Not to be confused with <literal>passphrase</literal>, + which is used with HTTPS Client Certificate authentication. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.local-cert"> + <term> + <parameter>local_cert</parameter> + <type>string</type> + </term> + <listitem> + <para> + Path to a client certificate for use with HTTPS authentication. + It must be a PEM encoded file which contains your certificate + and private key. + </para> + <para> + The file can also include a chain of issuers, which must come + after the client certificate. + </para> + <para> + Can also be set via + <link linkend="soapclient.construct.options.stream-context"> + <parameter>stream_context</parameter></link>, + which also supports specifying a separate private key file. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.passphrase"> + <term> + <parameter>passphrase</parameter> + <type>string</type> + </term> + <listitem> + <para> + Passphrase for the client certificate specified in the + <literal>local_cert</literal> option. + </para> + <para> + Not to be confused with <literal>password</literal>, + which is used for Basic or Digest Authentication. + </para> + <para> + Can also be set via + <link linkend="soapclient.construct.options.stream-context"> + <parameter>stream_context</parameter></link>. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.proxy-host"> + <term> + <parameter>proxy_host</parameter> + <type>string</type> + </term> + <listitem> + <para> + Hostname to use as a proxy server for HTTP requests. + </para> + <para> + The <literal>proxy_port</literal> option must also be specified. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.proxy-port"> + <term> + <parameter>proxy_port</parameter> + <type>int</type> + </term> + <listitem> + <para> + TCP port to use when connecting to the proxy server + specified in <literal>proxy_host</literal>. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.proxy-login"> + <term> + <parameter>proxy_login</parameter> + <type>string</type> + </term> + <listitem> + <para> + Optional username to authenticate with the proxy server + specified in <literal>proxy_host</literal>, using HTTP + Basic Authentication. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.proxy-password"> + <term> + <parameter>proxy_password</parameter> + <type>string</type> + </term> + <listitem> + <para> + Optional password to authenticate with the proxy server + specified in <literal>proxy_host</literal>, using HTTP + Basic Authentication. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.compression"> + <term> + <parameter>compression</parameter> + <type>int</type> + </term> + <listitem> + <para> + Enables compression of HTTP SOAP requests and responses. + </para> + <para> + The value should be the bitwise OR of three parts: + an optional <constant>SOAP_COMPRESSION_ACCEPT</constant>, + to send an "Accept-Encoding" header; either + <constant>SOAP_COMPRESSION_GZIP</constant> + or <constant>SOAP_COMPRESSION_DEFLATE</constant> to indicate + the compression algorithm to use; and a number between 1 and 9 + to indicate the level of compression to use in the request. + For example, to enable two-way gzip compression with the maximum + compression level, use + <literal>SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9</literal>. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.encoding"> + <term> + <parameter>encoding</parameter> + <type>string</type> + </term> + <listitem> + <para> + Defines the internal character encoding. Requests are always sent + in UTF-8, and converted to and from this encoding. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.trace"> + <term> + <parameter>trace</parameter> + <type>bool</type> + </term> + <listitem> + <para> + Captures request and response information, which can then be + accessed with the methods + <methodname>SoapClient::getLastRequest</methodname>, + <methodname>SoapClient::getLastRequestHeaders</methodname>, + <methodname>SoapClient::getLastResponse</methodname>, + and <methodname>SoapClient::getLastResponseHeaders</methodname>. + </para> + <para> + If omitted, defaults to &false; + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.classmap"> + <term> + <parameter>classmap</parameter> + <type>array</type> + </term> + <listitem> + <para> + Used to map types defined in the WSDL to PHP classes. + It should be specified as an associative <type>array</type> with + type names from the WSDL as keys and names of PHP classes as values. + Note that the type names of an element is not necessarily the same as + the element (tag) name. + </para> + <para> + The provided class names should always be fully qualified with any + <link linkend="language.namespaces">namespaces</link>, and never + start with a leading <literal>\</literal>. The correct form can be + generated by using + <link linkend="language.oop5.basic.class.class">::class</link>. + </para> + <para> + Note that when creating a class, the constructor will not be called, + but magic <link linkend="object.set">__set()</link> and + <link linkend="object.get">__get()</link> methods for individual + properties will be. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.typemap"> + <term> + <parameter>typemap</parameter> + <type>array</type> + </term> + <listitem> + <para> + Used to define type mappings using user-defined callback functions. + Each type mapping should be an array with keys + <literal>type_name</literal> (<type>string</type> specifying the + XML element type); + <literal>type_ns</literal> (<type>string</type> containing namespace + URI); + <literal>from_xml</literal> (<type>callable</type> accepting one + string parameter and returning an object) and + <literal>to_xml</literal> (<type>callable</type> accepting one + object parameter and returning a string). + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.exceptions"> + <term> + <parameter>exceptions</parameter> + <type>bool</type> + </term> + <listitem> + <para> + Defines whether errors throw exceptions of type + <classname>SoapFault</classname>. + </para> + <para> + Defaults to &true; + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.connection-timeout"> + <term> + <parameter>connection_timeout</parameter> + <type>int</type> + </term> + <listitem> + <para> + Defines a timeout in seconds for the connection to the SOAP service. + This option does not define a timeout for services with slow responses. + To limit the time to wait for calls to finish the + <link linkend="ini.default-socket-timeout">default_socket_timeout</link> + configuration option is available. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.cache-wsdl"> + <term> + <parameter>cache_wsdl</parameter> + <type>int</type> + </term> + <listitem> + <para> + If the <parameter>wsdl</parameter> parameter is provided, and the + <link linkend="ini.soap.wsdl-cache-enabled">soap.wsdl_cache_enabled</link> + configuration option is on, this option determines the type of caching. + One of <constant>WSDL_CACHE_NONE</constant>, + <constant>WSDL_CACHE_DISK</constant>, + <constant>WSDL_CACHE_MEMORY</constant> or + <constant>WSDL_CACHE_BOTH</constant>. + </para> + <para> + Two types of cache are available: in-memory caching, which caches the WSDL + in the memory of the current process; and disk caching, which caches the + WSDL in a file on disk, shared between all processes. + The directory to use for the disk cache is determined by the + <link linkend="ini.soap.wsdl-cache-dir">soap.wsdl_cache_dir</link> + configuration option. + Both caches use the same lifetime, determined by the + <link linkend="ini.soap.wsdl-cache-ttl">soap.wsdl_cache_ttl</link> + configuration option. The in-memory cache also has a maximum number of entries + determined by the + <link linkend="ini.soap.wsdl-cache-limit">soap.wsdl_cache_limit</link> + configuration option. + </para> + <para> + If not specified, the <link linkend="ini.soap.wsdl-cache"> + soap.wsdl_cache</link> configuration option will be used. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.user-agent"> + <term> + <parameter>user_agent</parameter> + <type>string</type> + </term> + <listitem> + <para> + The value to use in the <literal>User-Agent</literal> HTTP header + when making requests. + </para> + <para> + Can also be set via <link linkend="soapclient.construct.options.stream-context"> + <parameter>stream_context</parameter></link>. + </para> + <para> + If not specified, the user agent will be <literal>"PHP-SOAP/"</literal> + followed by the value of <constant>PHP_VERSION</constant>. + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.stream-context"> + <term> + <parameter>stream_context</parameter> + <type>resource</type> + </term> + <listitem> + <para> + A <link linkend="context">stream context</link> created by + <function>stream_context_create</function>, which allows additional + options to be set. + </para> + <para> + The context may include <link linkend="context.socket">socket context options</link>, + <link linkend="context.ssl">SSL context options</link>, + plus selected <link linkend="context.http">HTTP context options</link>: + <literal>content_type</literal>, <literal>header</literal>, + <literal>max_redirects</literal>, <literal>protocol_version</literal>, + and <literal>user_agent</literal>. + </para> + <para> + Note that the following HTTP headers are generated automatically or from other + options, and will be ignored if specified in the <literal>'header'</literal> + context option: <literal>host</literal>, <literal>connection</literal>, + <literal>user-agent</literal>, <literal>content-length</literal>, + <literal>content-type</literal>, <literal>cookie</literal>, + <literal>authorization</literal>, and <literal>proxy-authorization</literal> + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.features"> + <term> + <parameter>features</parameter> + <type>int</type> + </term> + <listitem> + <para> + A bitmask to enable one or more of the following features: + <variablelist> + <varlistentry> + <term> + <constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant> + </term> + <listitem> + <para> + When decoding a response to an array, the default behaviour is to detect whether + an element name appears once or multiple times in a particular parent element. + For elements which appear only once, an object property allows direct access to + the content; for elements which appear more than once, the property contains an + array with the content of each matching element. + </para> + <para> + If the <constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant> feature is enabled, + elements which appear only once are placed in a single-element array, so that + access is consistent for all elements. This only has an effect when using a WSDL + containing a schema for the response. See Examples section for an illustration. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>SOAP_USE_XSI_ARRAY_TYPE</constant> + </term> + <listitem> + <para> + When the <link linkend="soapclient.construct.options.use"><literal>use</literal> + option</link> or WSDL property is set to <literal>encoded</literal>, + force arrays to use a type of <literal>SOAP-ENC:Array</literal>, rather than a + schema-specific type. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>SOAP_WAIT_ONE_WAY_CALLS</constant> + </term> + <listitem> + <para> + Wait for a response even if the WSDL indicates a one-way request. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.keep-alive"> + <term> + <parameter>keep_alive</parameter> + <type>bool</type> + </term> + <listitem> + <para> + a boolean value defining whether + to send the <literal>Connection: Keep-Alive</literal> header or + <literal>Connection: close</literal>. + </para> + <para> + Defaults to &true; + </para> + </listitem> + </varlistentry> + <varlistentry xml:id="soapclient.construct.options.ssl-method"> + <term> + <parameter>ssl_method</parameter> + <type>string</type> + </term> + <listitem> + <para> + Specifies the SSL or TLS protocol version to use with secure HTTP + connections, instead of the default negotiation. + Specifying <constant>SOAP_SSL_METHOD_SSLv2</constant> + or <constant>SOAP_SSL_METHOD_SSLv3</constant> will force use of SSL 2 + or SSL 3, respectively. + Specifying <constant>SOAP_SSL_METHOD_SSLv23</constant> has no effect; + the constant exists only for backwards compatibility. + As of PHP 7.2, specifying <constant>SOAP_SSL_METHOD_TLS</constant> + also has no effect; in earlier versions, it forced use of TLS 1.0. + </para> + <para> + Note that SSL versions 2 and 3 are considered insecure, and may not + be supported by the installed OpenSSL library. + </para> + <para> + This option is <emphasis>DEPRECATED</emphasis> as of PHP 8.1.0. + A more flexible alternative, which allows specifying + individual versions of TLS, is to use the + <link linkend="soapclient.construct.options.stream-context"> + <parameter>stream_context</parameter></link> option with + the 'crypto_method' context parameter. + <example> + <title>Specifying use of TLS 1.3 only</title> + <programlisting role="php"> +<![CDATA[ +<?php +$context = stream_context_create([ + 'ssl' => [ + 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT + ] +]; +$client = new SoapClient("some.wsdl", ['context' => $context]); +]]> + </programlisting> + </example> + </para> + </listitem> + </varlistentry> + </variablelist> </para> </listitem> </varlistentry> @@ -178,7 +646,9 @@ &reftitle.examples; <para> <example> - <title><function>SoapClient::__construct</function> example</title> + <title> + <methodname>SoapClient::__construct</methodname> example + </title> <programlisting role="php"> <![CDATA[ <?php @@ -209,7 +679,7 @@ $client = new SoapClient(null, array('location' => "http://localhost/soap.php", 'use' => SOAP_LITERAL)); $client = new SoapClient("some.wsdl", - array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP)); + array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9)); $client = new SoapClient("some.wsdl", array('encoding'=>'ISO-8859-1')); @@ -220,11 +690,86 @@ class MyBook { $client = new SoapClient("books.wsdl", array('classmap' => array('book' => "MyBook"))); +$typemap = array( + array("type_ns" => "http://schemas.example.com", + "type_name" => "book", + "from_xml" => "unserialize_book" + "to_xml" => "serialize_book") +); +$client = new SoapClient("books.wsdl", array('typemap' => $typemap)); + ?> ]]> </programlisting> </example> </para> + + <para> + <example> + <title>Using the <constant>SOAP_SINGLE_ELEMENT_ARRAYS</constant> feature</title> + <programlisting role="php"> +<![CDATA[ +/* Assuming a response like this, and an appropriate WSDL: +<?xml version="1.0" encoding="UTF-8"?> +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:example"> + <SOAP-ENV:Body> + <response> + <collection> + <item>Single</item> + </collection> + <collection> + <item>First</item> + <item>Second</item> + </collection> + </response> + </SOAP-ENV:Body> +</SOAP-ENV:Envelope> +*/ + +echo "Default:\n"; + +$client = new TestSoapClient(__DIR__ . '/temp.wsdl'); +$response = $client->exampleRequest(); +var_dump( $response->collection[0]->item ); +var_dump( $response->collection[1]->item ); + +echo "\nWith SOAP_SINGLE_ELEMENT_ARRAYS:\n"; + +$client = new TestSoapClient(__DIR__ . '/temp.wsdl', ['features' => SOAP_SINGLE_ELEMENT_ARRAYS]); +$response = $client->exampleRequest(); +var_dump( $response->collection[0]->item ); +var_dump( $response->collection[1]->item ); +]]> + </programlisting> + + &example.outputs; + + <screen> +<![CDATA[ +Default: +string(6) "Single" +array(2) { + [0] => + string(5) "First" + [1] => + string(6) "Second" +} + +With SOAP_SINGLE_ELEMENT_ARRAYS: +array(1) { + [0] => + string(6) "Single" +} +array(2) { + [0] => + string(5) "First" + [1] => + string(6) "Second" +} +]]> + </screen> + </example> + </para> </refsect1> </refentry>