mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
796 lines
29 KiB
XML
796 lines
29 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="soapclient.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>SoapClient::__construct</refname>
|
|
<refpurpose>SoapClient constructor</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<constructorsynopsis>
|
|
<modifier>public</modifier> <methodname>SoapClient::__construct</methodname>
|
|
<methodparam><type class="union"><type>string</type><type>null</type></type><parameter>wsdl</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
|
|
</constructorsynopsis>
|
|
<para>
|
|
Creates a <classname>SoapClient</classname> object to connect to a SOAP service.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>wsdl</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
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>
|
|
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>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>options</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
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>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
<methodname>SoapClient::__construct</methodname> will generate an
|
|
<constant>E_ERROR</constant> error if the <literal>location</literal> and
|
|
<literal>uri</literal> options aren't provided in non-WSDL mode.
|
|
</para>
|
|
<para>
|
|
A <classname>SoapFault</classname> exception will be thrown if the
|
|
<parameter>wsdl</parameter> URI cannot be loaded.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>
|
|
<methodname>SoapClient::__construct</methodname> example
|
|
</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?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("some.wsdl", array('local_cert' => "cert_key.pem"));
|
|
|
|
$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));
|
|
|
|
$client = new SoapClient("some.wsdl",
|
|
array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9));
|
|
|
|
$client = new SoapClient("some.wsdl", array('encoding'=>'ISO-8859-1'));
|
|
|
|
class MyBook {
|
|
public $title;
|
|
public $author;
|
|
}
|
|
|
|
$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>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|