1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.soap.client">
4 <title>Zend_Soap_Client</title>
7 The <classname>Zend_Soap_Client</classname> class simplifies <acronym>SOAP</acronym> client
8 development for <acronym>PHP</acronym> programmers.
12 It may be used in WSDL or non-WSDL mode.
16 Under the WSDL mode, the <classname>Zend_Soap_Client</classname> component uses a WSDL
17 document to define transport layer options.
21 The WSDL description is usually provided by the web service the client will access. If the
22 WSDL description is not made available, you may want to use
23 <classname>Zend_Soap_Client</classname> in non-WSDL mode. Under this mode, all
24 <acronym>SOAP</acronym> protocol options have to be set explicitly on the
25 <classname>Zend_Soap_Client</classname> class.
28 <sect2 id="zend.soap.client.constructor">
29 <title>Zend_Soap_Client Constructor</title>
32 The <classname>Zend_Soap_Client</classname> constructor takes two parameters:
37 <varname>$wsdl</varname> - the <acronym>URI</acronym> of a WSDL file.
43 <varname>$options</varname> - options to create <acronym>SOAP</acronym>
49 Both of these parameters may be set later using <methodname>setWsdl($wsdl)</methodname>
50 and <methodname>setOptions($options)</methodname> methods respectively.
54 <title>Important!</title>
57 If you use <classname>Zend_Soap_Client</classname> component in non-WSDL mode, you
58 <emphasis>must</emphasis> set the 'location' and 'uri' options.
63 The following options are recognized:
68 'soap_version' ('soapVersion') - soap version to use (SOAP_1_1 or
69 <acronym>SOAP</acronym>_1_2).
75 'classmap' ('classMap') - can be used to map some WSDL types to
76 <acronym>PHP</acronym> classes.
80 The option must be an array with WSDL types as keys and names of
81 <acronym>PHP</acronym> classes as values.
87 'encoding' - internal character encoding (UTF-8 is always used as an
94 'wsdl' which is equivalent to <methodname>setWsdl($wsdlValue)</methodname>
99 Changing this option may switch <classname>Zend_Soap_Client</classname>
100 object to or from WSDL mode.
106 'uri' - target namespace for the <acronym>SOAP</acronym> service (required
107 for non-WSDL-mode, doesn't work for WSDL mode).
113 'location' - the <acronym>URL</acronym> to request (required for
114 non-WSDL-mode, doesn't work for WSDL mode).
120 'style' - request style (doesn't work for WSDL mode):
121 <constant>SOAP_RPC</constant> or <constant>SOAP_DOCUMENT</constant>.
127 'use' - method to encode messages (doesn't work for WSDL mode):
128 <constant>SOAP_ENCODED</constant> or <constant>SOAP_LITERAL</constant>.
134 'login' and 'password' - login and password for an <acronym>HTTP</acronym>
141 'proxy_host', 'proxy_port', 'proxy_login', and 'proxy_password' - an
142 <acronym>HTTP</acronym> connection through a proxy server.
148 'local_cert' and 'passphrase' - <acronym>HTTPS</acronym> client certificate
149 authentication options.
155 'compression' - compression options; it's a combination of
156 <constant>SOAP_COMPRESSION_ACCEPT</constant>,
157 <constant>SOAP_COMPRESSION_GZIP</constant> and
158 <constant>SOAP_COMPRESSION_DEFLATE</constant> options which may be used like
162 <programlisting language="php"><![CDATA[
163 // Accept response compression
164 $client = new Zend_Soap_Client("some.wsdl",
165 array('compression' => SOAP_COMPRESSION_ACCEPT));
168 // Compress requests using gzip with compression level 5
169 $client = new Zend_Soap_Client("some.wsdl",
170 array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5));
173 // Compress requests using deflate compression
174 $client = new Zend_Soap_Client("some.wsdl",
175 array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE));
182 <sect2 id="zend.soap.client.calls">
183 <title>Performing SOAP Requests</title>
186 After we've created a <classname>Zend_Soap_Client</classname> object we are ready to
187 perform <acronym>SOAP</acronym> requests.
191 Each web service method is mapped to the virtual <classname>Zend_Soap_Client</classname>
192 object method which takes parameters with common <acronym>PHP</acronym> types.
196 Use it like in the following example:
199 <programlisting language="php"><![CDATA[
200 //****************************************************************
202 //****************************************************************
205 // * This method takes ...
207 // * @param integer $inputParam
210 // public function method1($inputParam) {
215 // * This method takes ...
217 // * @param integer $inputParam1
218 // * @param string $inputParam2
221 // public function method2($inputParam1, $inputParam2) {
228 // $server = new Zend_Soap_Server(null, $options);
229 // $server->setClass('MyClass');
231 // $server->handle();
233 //****************************************************************
234 // End of server code
235 //****************************************************************
237 $client = new Zend_Soap_Client("MyService.wsdl");
240 // $result1 is a string
241 $result1 = $client->method1(10);
244 // $result2 is a float
245 $result2 = $client->method2(22, 'some string');