<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.soapclient.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'soapclient.construct.php',
    1 => 'SoapClient::__construct',
    2 => 'SoapClient constructor',
  ),
  'up' => 
  array (
    0 => 'class.soapclient.php',
    1 => 'SoapClient',
  ),
  'prev' => 
  array (
    0 => 'soapclient.call.php',
    1 => 'SoapClient::__call',
  ),
  'next' => 
  array (
    0 => 'soapclient.dorequest.php',
    1 => 'SoapClient::__doRequest',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/soap/soapclient/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="soapclient.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SoapClient::__construct</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SoapClient::__construct</span> &mdash; <span class="dc-title">SoapClient constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-soapclient.construct-description">
  <h3 class="title">Descrizione</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SoapClient::__construct</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$wsdl</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$options</code><span class="initializer"> = []</span></span>)</div>

  <p class="para rdfs-comment">
   Creates a <span class="classname"><a href="class.soapclient.php" class="classname">SoapClient</a></span> object to connect to a SOAP service.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-soapclient.construct-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">wsdl</code></dt>
     <dd>
      <p class="para">
       URI of a <abbr title="Web Services Description Language">WSDL</abbr> file describing the service, which is used to automatically
       configure the client. If not provided, the client will operate in non-WSDL
       mode.
      </p>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <p class="para">
        By default, the WSDL file will be cached for performance. To disable
        or configure this caching, see
        <a href="soap.configuration.php#soap.configuration.list" class="link">SOAP Opzioni di configurazione</a>
        and the <a href="soapclient.construct.php#soapclient.construct.options.cache-wsdl" class="link">
        <code class="literal">cache_wsdl</code> option</a>.
       </p>
      </p></blockquote>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       An associative array specifying additional options for the SOAP client.
       If <code class="parameter">wsdl</code> is provided, this is optional; otherwise,
       at least <code class="literal">location</code> and <code class="literal">url</code> must be
       provided.
       <dl>
        
         <dt id="soapclient.construct.options.location">
          <code class="parameter">location</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           The URL of the SOAP server to send the request to.
          </p>
          <p class="para">
           Required if the <code class="parameter">wsdl</code> parameter is not provided.
           If both a <code class="parameter">wsdl</code> parameter and
           <code class="literal">location</code> option are provided, the
           <code class="literal">location</code> option will over-ride any location
           specified in the WSDL file.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.uri">
          <code class="parameter">uri</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           The target namespace of the SOAP service.
          </p>
          <p class="para">
           Required if the <code class="parameter">wsdl</code> parameter is not provided;
           ignored otherwise.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.style">
          <code class="parameter">style</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="para">
           Specifies the binding style to use for this client, using the constants
           <strong><code><a href="soap.constants.php#constant.soap-rpc">SOAP_RPC</a></code></strong> and <strong><code><a href="soap.constants.php#constant.soap-document">SOAP_DOCUMENT</a></code></strong>.
           <strong><code><a href="soap.constants.php#constant.soap-rpc">SOAP_RPC</a></code></strong> indicates RPC-style binding, where the
           SOAP request body contains a standard encoding of a function call.
           <strong><code><a href="soap.constants.php#constant.soap-document">SOAP_DOCUMENT</a></code></strong> indicates document-style binding,
           where the SOAP request body contains an XML document with
           service-defined meaning.
          </p>
          <p class="para">
           If the <code class="parameter">wsdl</code> parameter is provided, this
           option is ignored, and the style is read from the WSDL file.
          </p>
          <p class="para">
           If neither this option nor the <code class="parameter">wsdl</code> parameter
           is provided, RPC-style is used.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.use">
          <code class="parameter">use</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="para">
           Specifies the encoding style to use for this client, using the
           constants <strong><code><a href="soap.constants.php#constant.soap-encoded">SOAP_ENCODED</a></code></strong> or <strong><code><a href="soap.constants.php#constant.soap-literal">SOAP_LITERAL</a></code></strong>.
           <strong><code><a href="soap.constants.php#constant.soap-encoded">SOAP_ENCODED</a></code></strong> indicates encoding using the types
           defined in the SOAP specification.
           <strong><code><a href="soap.constants.php#constant.soap-literal">SOAP_LITERAL</a></code></strong> indicates encoding using a schema
           defined by the service.
          </p>
          <p class="para">
           If the <code class="parameter">wsdl</code> parameter is provided, this
           option is ignored, and the encoding is read from the WSDL file.
          </p>
          <p class="para">
           If neither this option nor the <code class="parameter">wsdl</code> parameter
           is provided, the &quot;encoded&quot; style is used.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.soap-version">
          <code class="parameter">soap_version</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="para">
           Specifies the version of the SOAP protocol to use:
           <strong><code><a href="soap.constants.php#constant.soap-1-1">SOAP_1_1</a></code></strong> for SOAP 1.1,
           or <strong><code><a href="soap.constants.php#constant.soap-1-2">SOAP_1_2</a></code></strong> for SOAP 1.2.
          </p>
          <p class="para">
           If omitted, SOAP 1.1 is used.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.authentication">
          <code class="parameter">authentication</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="para">
           Specifies the authentication method when using HTTP authentication
           in requests. The value may be either
           <strong><code><a href="soap.constants.php#constant.soap-authentication-basic">SOAP_AUTHENTICATION_BASIC</a></code></strong>
           or <strong><code><a href="soap.constants.php#constant.soap-authentication-digest">SOAP_AUTHENTICATION_DIGEST</a></code></strong>.
          </p>
          <p class="para">
           If omitted, and the <code class="literal">login</code> option is provided,
           Basic Authentication is used.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.login">
          <code class="parameter">login</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Username to use with HTTP Basic or Digest Authentication.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.password">
          <code class="parameter">password</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Password to use with HTTP Basic or Digest Authentication.
          </p>
          <p class="para">
           Not to be confused with <code class="literal">passphrase</code>,
           which is used with HTTPS Client Certificate authentication.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.local-cert">
          <code class="parameter">local_cert</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Path to a client certificate for use with HTTPS authentication.
           It must be a <abbr title="Privacy-Enhanced Mail">PEM</abbr> encoded file which contains the certificate
           and private key.
          </p>
          <p class="para">
           The file can also include a chain of issuers, which must come
           after the client certificate.
          </p>
          <p class="para">
           Can also be set via
           <a href="soapclient.construct.php#soapclient.construct.options.stream-context" class="link">
           <code class="parameter">stream_context</code></a>,
           which also supports specifying a separate private key file.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.passphrase">
          <code class="parameter">passphrase</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Passphrase for the client certificate specified in the
           <code class="literal">local_cert</code> option.
          </p>
          <p class="para">
           Not to be confused with <code class="literal">password</code>,
           which is used for Basic or Digest Authentication.
          </p>
          <p class="para">
           Can also be set via
           <a href="soapclient.construct.php#soapclient.construct.options.stream-context" class="link">
           <code class="parameter">stream_context</code></a>.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.proxy-host">
          <code class="parameter">proxy_host</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Hostname to use as a proxy server for HTTP requests.
          </p>
          <p class="para">
           The <code class="literal">proxy_port</code> option must also be specified.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.proxy-port">
          <code class="parameter">proxy_port</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="para">
           TCP port to use when connecting to the proxy server
           specified in <code class="literal">proxy_host</code>.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.proxy-login">
          <code class="parameter">proxy_login</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Optional username to authenticate with the proxy server
           specified in <code class="literal">proxy_host</code>, using HTTP
           Basic Authentication.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.proxy-password">
          <code class="parameter">proxy_password</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Optional password to authenticate with the proxy server
           specified in <code class="literal">proxy_host</code>, using HTTP
           Basic Authentication.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.compression">
          <code class="parameter">compression</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="para">
           Enables compression of HTTP SOAP requests and responses.
          </p>
          <p class="para">
           The value should be the bitwise OR of three parts:
           an optional <strong><code><a href="soap.constants.php#constant.soap-compression-accept">SOAP_COMPRESSION_ACCEPT</a></code></strong>,
           to send an &quot;Accept-Encoding&quot; header; either
           <strong><code><a href="soap.constants.php#constant.soap-compression-gzip">SOAP_COMPRESSION_GZIP</a></code></strong>
           or <strong><code><a href="soap.constants.php#constant.soap-compression-deflate">SOAP_COMPRESSION_DEFLATE</a></code></strong> 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
           <code class="literal">SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9</code>.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.encoding">
          <code class="parameter">encoding</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Defines the internal character encoding. Requests are always sent
           in UTF-8, and converted to and from this encoding.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.trace">
          <code class="parameter">trace</code>
          <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
         </dt>
         <dd>
          <p class="para">
           Captures request and response information, which can then be
           accessed with the methods
           <span class="methodname"><a href="soapclient.getlastrequest.php" class="methodname">SoapClient::__getLastRequest()</a></span>,
           <span class="methodname"><a href="soapclient.getlastrequestheaders.php" class="methodname">SoapClient::__getLastRequestHeaders()</a></span>,
           <span class="methodname"><a href="soapclient.getlastresponse.php" class="methodname">SoapClient::__getLastResponse()</a></span>,
           and <span class="methodname"><a href="soapclient.getlastresponseheaders.php" class="methodname">SoapClient::__getLastResponseHeaders()</a></span>.
          </p>
          <p class="para">
           If omitted, defaults to <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.classmap">
          <code class="parameter">classmap</code>
          <span class="type"><a href="language.types.array.php" class="type array">array</a></span>
         </dt>
         <dd>
          <p class="para">
           Used to map types defined in the WSDL to PHP classes.
           It should be specified as an associative <span class="type"><a href="language.types.array.php" class="type array">array</a></span> with
           type names from the WSDL as keys and names of PHP classes as values.
           Note that the type name of an element is not necessarily the same as
           the element (tag) name.
          </p>
          <p class="para">
           The provided class names should always be fully qualified with any
           <a href="language.namespaces.php" class="link">namespaces</a>, and never
           start with a leading <code class="literal">\</code>. The correct form can be
           generated by using
           <a href="language.oop5.basic.php#language.oop5.basic.class.class" class="link">::class</a>.
          </p>
          <p class="para">
           Note that when creating a class, the constructor will not be called,
           but magic <a href="language.oop5.overloading.php#object.set" class="link">__set()</a> and
           <a href="language.oop5.overloading.php#object.get" class="link">__get()</a> methods for individual
           properties will be.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.typemap">
          <code class="parameter">typemap</code>
          <span class="type"><a href="language.types.array.php" class="type array">array</a></span>
         </dt>
         <dd>
          <p class="para">
           Used to define type mappings using user-defined callback functions.
           Each type mapping should be an array with keys
           <code class="literal">type_name</code> (<span class="type"><a href="language.types.string.php" class="type string">string</a></span> specifying the
           XML element type);
           <code class="literal">type_ns</code> (<span class="type"><a href="language.types.string.php" class="type string">string</a></span> containing namespace
           URI);
           <code class="literal">from_xml</code> (<span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> accepting one
           string parameter and returning an object) and
           <code class="literal">to_xml</code> (<span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> accepting one
           object parameter and returning a string).
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.exceptions">
          <code class="parameter">exceptions</code>
          <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
         </dt>
         <dd>
          <p class="para">
           Defines whether errors throw exceptions of type
           <span class="classname"><a href="class.soapfault.php" class="classname">SoapFault</a></span>.
          </p>
          <p class="para">
           Defaults to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.connection-timeout">
          <code class="parameter">connection_timeout</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="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
           <a href="filesystem.configuration.php#ini.default-socket-timeout" class="link">default_socket_timeout</a>
           configuration option is available.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.cache-wsdl">
          <code class="parameter">cache_wsdl</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="para">
           If the <code class="parameter">wsdl</code> parameter is provided, and the
           <a href="soap.configuration.php#ini.soap.wsdl-cache-enabled" class="link">soap.wsdl_cache_enabled</a>
           configuration option is on, this option determines the type of caching.
           One of <strong><code><a href="soap.constants.php#constant.wsdl-cache-none">WSDL_CACHE_NONE</a></code></strong>,
           <strong><code><a href="soap.constants.php#constant.wsdl-cache-disk">WSDL_CACHE_DISK</a></code></strong>,
           <strong><code><a href="soap.constants.php#constant.wsdl-cache-memory">WSDL_CACHE_MEMORY</a></code></strong> or
           <strong><code><a href="soap.constants.php#constant.wsdl-cache-both">WSDL_CACHE_BOTH</a></code></strong>.
          </p>
          <p class="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
           <a href="soap.configuration.php#ini.soap.wsdl-cache-dir" class="link">soap.wsdl_cache_dir</a>
           configuration option.
           Both caches use the same lifetime, determined by the
           <a href="soap.configuration.php#ini.soap.wsdl-cache-ttl" class="link">soap.wsdl_cache_ttl</a>
           configuration option. The in-memory cache also has a maximum number of entries
           determined by the
           <a href="soap.configuration.php#ini.soap.wsdl-cache-limit" class="link">soap.wsdl_cache_limit</a>
           configuration option.
          </p>
          <p class="para">
           If not specified, the <a href="soap.configuration.php#ini.soap.wsdl-cache" class="link">
           soap.wsdl_cache</a> configuration option will be used.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.user-agent">
          <code class="parameter">user_agent</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           The value to use in the <code class="literal">User-Agent</code> HTTP header
           when making requests.
          </p>
          <p class="para">
           Can also be set via <a href="soapclient.construct.php#soapclient.construct.options.stream-context" class="link">
           <code class="parameter">stream_context</code></a>.
          </p>
          <p class="para">
           If not specified, the user agent will be <code class="literal">&quot;PHP-SOAP/&quot;</code>
           followed by the value of <strong><code><a href="reserved.constants.php#constant.php-version">PHP_VERSION</a></code></strong>.
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.stream-context">
          <code class="parameter">stream_context</code>
          <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>
         </dt>
         <dd>
          <p class="para">
           A <a href="context.php" class="link">stream context</a> created by
           <span class="function"><a href="function.stream-context-create.php" class="function">stream_context_create()</a></span>, which allows additional
           options to be set.
          </p>
          <p class="para">
           The context may include <a href="context.socket.php" class="link">socket context options</a>,
           <a href="context.ssl.php" class="link">SSL context options</a>,
           plus selected <a href="context.http.php" class="link">HTTP context options</a>:
           <code class="literal">content_type</code>, <code class="literal">header</code>,
           <code class="literal">max_redirects</code>, <code class="literal">protocol_version</code>,
           and <code class="literal">user_agent</code>.
          </p>
          <p class="para">
           Note that the following HTTP headers are generated automatically or from other
           options, and will be ignored if specified in the <code class="literal">&#039;header&#039;</code>
           context option: <code class="literal">host</code>, <code class="literal">connection</code>,
           <code class="literal">user-agent</code>, <code class="literal">content-length</code>,
           <code class="literal">content-type</code>, <code class="literal">cookie</code>,
           <code class="literal">authorization</code>, and <code class="literal">proxy-authorization</code>
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.features">
          <code class="parameter">features</code>
          <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
         </dt>
         <dd>
          <p class="para">
           A bitmask to enable one or more of the following features:
           <dl>
            
             <dt>
              <strong><code><a href="soap.constants.php#constant.soap-single-element-arrays">SOAP_SINGLE_ELEMENT_ARRAYS</a></code></strong>
             </dt>
             <dd>
              <p class="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.
              </p>
              <p class="para">
               If the <strong><code><a href="soap.constants.php#constant.soap-single-element-arrays">SOAP_SINGLE_ELEMENT_ARRAYS</a></code></strong> 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.
              </p>
             </dd>
            
            
             <dt>
              <strong><code><a href="soap.constants.php#constant.soap-use-xsi-array-type">SOAP_USE_XSI_ARRAY_TYPE</a></code></strong>
             </dt>
             <dd>
              <p class="para">
               When the <a href="soapclient.construct.php#soapclient.construct.options.use" class="link"><code class="literal">use</code>
               option</a> or WSDL property is set to <code class="literal">encoded</code>,
               force arrays to use a type of <code class="literal">SOAP-ENC:Array</code>, rather than a
               schema-specific type.
              </p>
             </dd>
            
            
             <dt>
              <strong><code><a href="soap.constants.php#constant.soap-wait-one-way-calls">SOAP_WAIT_ONE_WAY_CALLS</a></code></strong>
             </dt>
             <dd>
              <p class="para">
               Wait for a response even if the WSDL indicates a one-way request.
              </p>
             </dd>
            
           </dl>
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.keep-alive">
          <code class="parameter">keep_alive</code>
          <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
         </dt>
         <dd>
          <p class="para">
           a boolean value defining whether
           to send the <code class="literal">Connection: Keep-Alive</code> header or
           <code class="literal">Connection: close</code>.
          </p>
          <p class="para">
           Defaults to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>
          </p>
         </dd>
        
        
         <dt id="soapclient.construct.options.ssl-method">
          <code class="parameter">ssl_method</code>
          <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
         </dt>
         <dd>
          <p class="para">
           Specifies the SSL or TLS protocol version to use with secure HTTP
           connections, instead of the default negotiation.
           Specifying <strong><code><a href="soap.constants.php#constant.soap-ssl-method-sslv2">SOAP_SSL_METHOD_SSLv2</a></code></strong>
           or <strong><code><a href="soap.constants.php#constant.soap-ssl-method-sslv3">SOAP_SSL_METHOD_SSLv3</a></code></strong> will force use of SSL 2
           or SSL 3, respectively.
           Specifying <strong><code><a href="soap.constants.php#constant.soap-ssl-method-sslv23">SOAP_SSL_METHOD_SSLv23</a></code></strong> has no effect;
           the constant exists only for backwards compatibility.
           As of PHP 7.2.0, specifying <strong><code><a href="soap.constants.php#constant.soap-ssl-method-tls">SOAP_SSL_METHOD_TLS</a></code></strong>
           also has no effect; in earlier versions, it forced use of TLS 1.0.
          </p>
          <p class="para">
           Note that SSL versions 2 and 3 are considered insecure, and may not
           be supported by the installed OpenSSL library.
          </p>
          <p class="para">
           This option is <strong>deprecated</strong> as of PHP 8.1.0.
           A more flexible alternative, which allows specifying
           individual versions of TLS, is to use the
           <a href="soapclient.construct.php#soapclient.construct.options.stream-context" class="link">
           <code class="parameter">stream_context</code></a> option with
           the &#039;crypto_method&#039; context parameter.
           <div class="informalexample">
            <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Specifying use of TLS 1.3 only<br /></span><span style="color: #0000BB">$context </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_context_create</span><span style="color: #007700">([<br />    </span><span style="color: #DD0000">'ssl' </span><span style="color: #007700">=&gt; [<br />        </span><span style="color: #DD0000">'crypto_method' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT<br />     </span><span style="color: #007700">]<br />]);<br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">, [</span><span style="color: #DD0000">'context' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$context</span><span style="color: #007700">]);</span></span></code></div>
            </div>

           </div>
          </p>
         </dd>
        
       </dl>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-soapclient.construct-errors">
  <h3 class="title">Errori/Eccezioni</h3>
  <p class="para">
   <span class="methodname"><strong>SoapClient::__construct()</strong></span> will generate an
   <strong><code><a href="errorfunc.constants.php#constant.e-error">E_ERROR</a></code></strong> error if the <code class="literal">location</code> and
   <code class="literal">uri</code> options aren&#039;t provided in non-WSDL mode.
  </p>
  <p class="para">
   A <span class="classname"><a href="class.soapfault.php" class="classname">SoapFault</a></span> exception will be thrown if the
   <code class="parameter">wsdl</code> URI cannot be loaded.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-soapclient.construct-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 
     <span class="methodname"><strong>SoapClient::__construct()</strong></span> example
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'soap_version'   </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">SOAP_1_2</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'login'          </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"some_name"</span><span style="color: #007700">,<br />                                            </span><span style="color: #DD0000">'password'       </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"some_password"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'proxy_host'     </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,<br />                                            </span><span style="color: #DD0000">'proxy_port'     </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">8080</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'proxy_host'     </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,<br />                                            </span><span style="color: #DD0000">'proxy_port'     </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">8080</span><span style="color: #007700">,<br />                                            </span><span style="color: #DD0000">'proxy_login'    </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"some_name"</span><span style="color: #007700">,<br />                                            </span><span style="color: #DD0000">'proxy_password' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"some_password"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'local_cert'     </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"cert_key.pem"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'location' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"http://localhost/soap.php"</span><span style="color: #007700">,<br />                                     </span><span style="color: #DD0000">'uri'      </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"http://test-uri/"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'location' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"http://localhost/soap.php"</span><span style="color: #007700">,<br />                                     </span><span style="color: #DD0000">'uri'      </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"http://test-uri/"</span><span style="color: #007700">,<br />                                     </span><span style="color: #DD0000">'style'    </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">SOAP_DOCUMENT</span><span style="color: #007700">,<br />                                     </span><span style="color: #DD0000">'use'      </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">SOAP_LITERAL</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,<br />  array(</span><span style="color: #DD0000">'compression' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">SOAP_COMPRESSION_ACCEPT </span><span style="color: #007700">| </span><span style="color: #0000BB">SOAP_COMPRESSION_GZIP </span><span style="color: #007700">| </span><span style="color: #0000BB">9</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'encoding'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'ISO-8859-1'</span><span style="color: #007700">));<br /><br />class </span><span style="color: #0000BB">MyBook </span><span style="color: #007700">{<br />    public </span><span style="color: #0000BB">$title</span><span style="color: #007700">;<br />    public </span><span style="color: #0000BB">$author</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"books.wsdl"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'classmap' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">'book' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"MyBook"</span><span style="color: #007700">)));<br /><br /></span><span style="color: #0000BB">$typemap </span><span style="color: #007700">= array(<br />    array(</span><span style="color: #DD0000">"type_ns"  </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"http://schemas.example.com"</span><span style="color: #007700">,<br />         </span><span style="color: #DD0000">"type_name" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"book"</span><span style="color: #007700">,<br />         </span><span style="color: #DD0000">"from_xml"  </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"unserialize_book"</span><span style="color: #007700">,<br />         </span><span style="color: #DD0000">"to_xml"    </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"serialize_book"</span><span style="color: #007700">)<br />);<br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">SoapClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"books.wsdl"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'typemap' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$typemap</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>

  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Example #2 Using the <strong><code><a href="soap.constants.php#constant.soap-single-element-arrays">SOAP_SINGLE_ELEMENT_ARRAYS</a></code></strong> feature</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Assuming a response like this, and an appropriate WSDL:<br />&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:example"&gt;<br />    &lt;SOAP-ENV:Body&gt;<br />        &lt;response&gt;<br />            &lt;collection&gt;<br />                &lt;item&gt;Single&lt;/item&gt;<br />            &lt;/collection&gt;<br />            &lt;collection&gt;<br />                &lt;item&gt;First&lt;/item&gt;<br />                &lt;item&gt;Second&lt;/item&gt;<br />            &lt;/collection&gt;<br />        &lt;/response&gt;<br />    &lt;/SOAP-ENV:Body&gt;<br />&lt;/SOAP-ENV:Envelope&gt;<br />*/<br /><br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"Default:\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">TestSoapClient</span><span style="color: #007700">(</span><span style="color: #0000BB">__DIR__ </span><span style="color: #007700">. </span><span style="color: #DD0000">'/temp.wsdl'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$response </span><span style="color: #007700">= </span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exampleRequest</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">$response</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">collection</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">item </span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">$response</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">collection</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">item </span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"\nWith SOAP_SINGLE_ELEMENT_ARRAYS:\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= new </span><span style="color: #0000BB">TestSoapClient</span><span style="color: #007700">(</span><span style="color: #0000BB">__DIR__ </span><span style="color: #007700">. </span><span style="color: #DD0000">'/temp.wsdl'</span><span style="color: #007700">, [</span><span style="color: #DD0000">'features' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">SOAP_SINGLE_ELEMENT_ARRAYS</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">$response </span><span style="color: #007700">= </span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exampleRequest</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">$response</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">collection</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">item </span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">$response</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">collection</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">item </span><span style="color: #007700">);</span></span></code></div>
    </div>


    <div class="example-contents"><p>Il precedente esempio visualizzerà:</p></div>

    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Default:
string(6) &quot;Single&quot;
array(2) {
  [0] =&gt;
  string(5) &quot;First&quot;
  [1] =&gt;
  string(6) &quot;Second&quot;
}

With SOAP_SINGLE_ELEMENT_ARRAYS:
array(1) {
  [0] =&gt;
  string(6) &quot;Single&quot;
}
array(2) {
  [0] =&gt;
  string(5) &quot;First&quot;
  [1] =&gt;
  string(6) &quot;Second&quot;
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


</div><?php manual_footer($setup); ?>