Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 4340

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>SoapClient-&#62;__construct()</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="SOAP Functions"
HREF="ref.soap.html"><LINK
REL="PREVIOUS"
TITLE="SoapClient->__call()"
HREF="function.soap-soapclient-call.html"><LINK
REL="NEXT"
TITLE="SoapClient->__doRequest()"
HREF="function.soap-soapclient-dorequest.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.soap-soapclient-call.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.soap-soapclient-dorequest.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.soap-soapclient-construct"
></A
>SoapClient-&#62;__construct()</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN211318"
></A
><P
>    (no version information, might be only in CVS)</P
>SoapClient-&#62;__construct()&nbsp;--&nbsp;
   SoapClient constructor
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN211321"
></A
><H2
>说明</H2
>class <B
CLASS="classname"
>SoapClient</B
> { <BR
></BR
><B
CLASS="methodname"
>__construct</B
> ( mixed wsdl [, array options] )<BR
></BR
>}<P
>&#13;   This constructor creates <B
CLASS="classname"
>SoapClient</B
> objects 
   in <TT
CLASS="literal"
>WSDL</TT
> or <TT
CLASS="literal"
>non-WSDL</TT
> mode.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN211338"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>wsdl</CODE
></DT
><DD
><P
>&#13;       URI of the <TT
CLASS="literal"
>WSDL</TT
> file or <TT
CLASS="constant"
><B
>NULL</B
></TT
> if working in 
       <TT
CLASS="literal"
>non-WSDL</TT
> mode.
      </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
        During development stage, you may want to disable WSDL caching by the
        mean of the <TT
CLASS="literal"
>soap.wsdl_cache_ttl</TT
> <TT
CLASS="filename"
>php.ini</TT
> setting,
        otherwise changes made to the WSDL file will have no effect until
        <TT
CLASS="literal"
>soap.wsdl_cache_ttl</TT
> is expired. 
       </P
></BLOCKQUOTE
></DIV
></DD
><DT
><CODE
CLASS="parameter"
>options</CODE
></DT
><DD
><P
>&#13;       An array of options. If working in WSDL mode, this parameter is optional.
       If working in non-WSDL mode, you must set the <TT
CLASS="literal"
>location</TT
> 
       and <TT
CLASS="literal"
>uri</TT
> options, where <TT
CLASS="literal"
>location</TT
> is 
       the URL to request and <TT
CLASS="literal"
>uri</TT
> is the target namespace of the
       SOAP service.
      </P
><P
>&#13;       The <TT
CLASS="literal"
>style</TT
> and <TT
CLASS="literal"
>use</TT
> options only work in
       non-WSDL mode. In WSDL mode, they come from the WSDL file.
      </P
><P
>&#13;       The <TT
CLASS="literal"
>soap_version</TT
> option specifies whether to use SOAP
       1.1, or SOAP 1.2 client.
      </P
><P
>&#13;       For HTTP authentication, you may use the <TT
CLASS="literal"
>login</TT
> and
       <TT
CLASS="literal"
>password</TT
> options. For making an HTTP connection through
       a proxy server, use the options <TT
CLASS="literal"
>proxy_host</TT
>,
       <TT
CLASS="literal"
>proxy_port</TT
>, <TT
CLASS="literal"
>proxy_login</TT
>
       and <TT
CLASS="literal"
>proxy_password</TT
>.
       For HTTPS client certificate authentication use
       <TT
CLASS="literal"
>local_cert</TT
> and <TT
CLASS="literal"
>passphrase</TT
> options.
      </P
><P
>&#13;       The <TT
CLASS="literal"
>compression</TT
> option allows to use compression
       of HTTP SOAP requests and responses.
      </P
><P
>&#13;       The <TT
CLASS="literal"
>encoding</TT
> 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.
      </P
><P
>&#13;       The <TT
CLASS="literal"
>classmap</TT
> 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.
      </P
><P
>&#13;       Setting the boolean <TT
CLASS="literal"
>trace</TT
> option enables use of the
       methods <A
HREF="function.soap-soapclient-getlastrequest.html"
>&#13;       SoapClient-&#62;__getLastRequest</A
>, 
       <A
HREF="function.soap-soapclient-getlastrequestheaders.html"
>&#13;       SoapClient-&#62;__getLastRequestHeaders</A
>,
       <A
HREF="function.soap-soapclient-getlastresponse.html"
>&#13;       SoapClient-&#62;__getLastResponse</A
> and
       <A
HREF="function.soap-soapclient-getlastresponseheaders.html"
>&#13;       SoapClient-&#62;__getLastResponseHeaders</A
>.
      </P
><P
>&#13;       The <TT
CLASS="literal"
>exceptions</TT
> option is a boolean value defining whether
       soap errors throw exceptions of type <A
HREF="function.soap-soapfault-construct.html"
>&#13;       SoapFault</A
>.
      </P
><P
>&#13;       The <TT
CLASS="literal"
>connection_timeout</TT
> 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 
       <A
HREF="ref.filesystem.html#ini.default-socket-timeout"
>default_socket_timeout</A
> setting
       is available.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN211396"
></A
><H2
>范例</H2
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN211399"
></A
><P
><B
>例 1. SoapClient examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"some.wsdl"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"some.wsdl"</font><font color="#007700">, array(</font><font color="#DD0000">'soap_version'&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">SOAP_1_2</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"some.wsdl"</font><font color="#007700">, array(</font><font color="#DD0000">'login'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"some_name"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'password'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"some_password"</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"some.wsdl"</font><font color="#007700">, array(</font><font color="#DD0000">'proxy_host'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"localhost"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'proxy_port'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">8080</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"some.wsdl"</font><font color="#007700">, array(</font><font color="#DD0000">'proxy_host'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"localhost"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'proxy_port'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">8080</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'proxy_login'&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"some_name"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'proxy_password' </font><font color="#007700">=&gt; </font><font color="#DD0000">"some_password"</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"some.wsdl"</font><font color="#007700">, array(</font><font color="#DD0000">'local_cert'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"cert_key.pem"</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#0000BB">null</font><font color="#007700">, array(</font><font color="#DD0000">'location' </font><font color="#007700">=&gt; </font><font color="#DD0000">"http://localhost/soap.php"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'uri'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"http://test-uri/"</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#0000BB">null</font><font color="#007700">, array(</font><font color="#DD0000">'location' </font><font color="#007700">=&gt; </font><font color="#DD0000">"http://localhost/soap.php"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'uri'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"http://test-uri/"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'style'&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">SOAP_DOCUMENT</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'use'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">SOAP_LITERAL</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$client </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"some.wsdl"</font><font color="#007700">, <br />&nbsp;&nbsp;array(</font><font color="#DD0000">'compression' </font><font color="#007700">=&gt; </font><font color="#0000BB">SOAP_COMPRESSION_ACCEPT </font><font color="#007700">| </font><font color="#0000BB">SOAP_COMPRESSION_GZIP</font><font color="#007700">));<br /><br /></font><font color="#0000BB">$server </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"some.wsdl"</font><font color="#007700">, array(</font><font color="#DD0000">'encoding'</font><font color="#007700">=&gt;</font><font color="#DD0000">'ISO-8859-1'</font><font color="#007700">));<br /><br />class </font><font color="#0000BB">MyBook </font><font color="#007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">public $title</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">public $author</font><font color="#007700">;<br />}<br /><br /></font><font color="#0000BB">$server </font><font color="#007700">= new </font><font color="#0000BB">SoapClient</font><font color="#007700">(</font><font color="#DD0000">"books.wsdl"</font><font color="#007700">, array(</font><font color="#DD0000">'classmap' </font><font color="#007700">=&gt; array(</font><font color="#DD0000">'book' </font><font color="#007700">=&gt; </font><font color="#DD0000">"MyBook"</font><font color="#007700">)));<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.soap-soapclient-call.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.soap-soapclient-dorequest.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SoapClient-&#62;__call()</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.soap.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SoapClient-&#62;__doRequest()</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>