Zend_XmlRpc_Client.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.xmlrpc.client">
  4. <title>Zend_XmlRpc_Client</title>
  5. <sect2 id="zend.xmlrpc.client.introduction">
  6. <title>Introduction</title>
  7. <para>
  8. Zend Framework provides support for consuming remote <acronym>XML-RPC</acronym>
  9. services as a client in the <classname>Zend_XmlRpc_Client</classname>
  10. package. Its major features include automatic type conversion
  11. between <acronym>PHP</acronym> and <acronym>XML-RPC</acronym>, a server proxy object,
  12. and access to server introspection capabilities.
  13. </para>
  14. </sect2>
  15. <sect2 id="zend.xmlrpc.client.method-calls">
  16. <title>Method Calls</title>
  17. <para>
  18. The constructor of <classname>Zend_XmlRpc_Client</classname> receives the
  19. <acronym>URL</acronym> of the remote <acronym>XML-RPC</acronym> server endpoint as its
  20. first parameter. The new instance returned may be used to call any number of
  21. remote methods at that endpoint.
  22. </para>
  23. <para>
  24. To call a remote method with the <acronym>XML-RPC</acronym> client, instantiate it
  25. and use the <methodname>call()</methodname> instance method. The code sample
  26. below uses a demonstration <acronym>XML-RPC</acronym> server on the Zend Framework
  27. website. You can use it for testing or exploring the
  28. <classname>Zend_XmlRpc</classname> components.
  29. </para>
  30. <example id="zend.xmlrpc.client.method-calls.example-1">
  31. <title>XML-RPC Method Call</title>
  32. <programlisting language="php"><![CDATA[
  33. $client = new Zend_XmlRpc_Client('http://framework.zend.com/xmlrpc');
  34. echo $client->call('test.sayHello');
  35. // hello
  36. ]]></programlisting>
  37. </example>
  38. <para>
  39. The <acronym>XML-RPC</acronym> value returned from the remote method call will be
  40. automatically unmarshaled and cast to the equivalent <acronym>PHP</acronym> native
  41. type. In the example above, a <acronym>PHP</acronym> <type>String</type> is returned
  42. and is immediately ready to be used.
  43. </para>
  44. <para>
  45. The first parameter of the <methodname>call()</methodname> method receives the
  46. name of the remote method to call. If the remote method requires
  47. any parameters, these can be sent by supplying a second, optional
  48. parameter to <methodname>call()</methodname> with an <type>Array</type> of
  49. values to pass to the remote method:
  50. </para>
  51. <example id="zend.xmlrpc.client.method-calls.example-2">
  52. <title>XML-RPC Method Call with Parameters</title>
  53. <programlisting language="php"><![CDATA[
  54. $client = new Zend_XmlRpc_Client('http://framework.zend.com/xmlrpc');
  55. $arg1 = 1.1;
  56. $arg2 = 'foo';
  57. $result = $client->call('test.sayHello', array($arg1, $arg2));
  58. // $result is a native PHP type
  59. ]]></programlisting>
  60. </example>
  61. <para>
  62. If the remote method doesn't require parameters, this optional
  63. parameter may either be left out or an empty <methodname>array()</methodname>
  64. passed to it. The array of parameters for the remote method can
  65. contain native <acronym>PHP</acronym> types, <classname>Zend_XmlRpc_Value</classname>
  66. objects, or a mix of each.
  67. </para>
  68. <para>
  69. The <methodname>call()</methodname> method will automatically convert the
  70. <acronym>XML-RPC</acronym> response and return its equivalent <acronym>PHP</acronym>
  71. native type. A <classname>Zend_XmlRpc_Response</classname> object for the return value
  72. will also be available by calling the <methodname>getLastResponse()</methodname>
  73. method after the call.
  74. </para>
  75. </sect2>
  76. <sect2 id="zend.xmlrpc.value.parameters">
  77. <title>Types and Conversions</title>
  78. <para>
  79. Some remote method calls require parameters. These are given to
  80. the <methodname>call()</methodname> method of <classname>Zend_XmlRpc_Client</classname>
  81. as an array in the second parameter. Each parameter may be
  82. given as either a native <acronym>PHP</acronym> type which will be automatically
  83. converted, or as an object representing a specific <acronym>XML-RPC</acronym> type
  84. (one of the <classname>Zend_XmlRpc_Value</classname> objects).
  85. </para>
  86. <sect3 id="zend.xmlrpc.value.parameters.php-native">
  87. <title>PHP Native Types as Parameters</title>
  88. <para>
  89. Parameters may be passed to <methodname>call()</methodname> as native <acronym>PHP</acronym>
  90. variables, meaning as a <type>String</type>,
  91. <code>integer</code>, <code>float</code>,
  92. <type>Boolean</type>, <type>Array</type>, or an
  93. <code>object</code>. In this case, each <acronym>PHP</acronym> native type will
  94. be auto-detected and converted into one of the <acronym>XML-RPC</acronym> types
  95. according to this table:
  96. </para>
  97. <table id="zend.xmlrpc.value.parameters.php-native.table-1">
  98. <title>PHP and XML-RPC Type Conversions</title>
  99. <tgroup cols="2">
  100. <thead>
  101. <row>
  102. <entry><acronym>PHP</acronym> Native Type</entry>
  103. <entry><acronym>XML-RPC</acronym> Type</entry>
  104. </row>
  105. </thead>
  106. <tbody>
  107. <row>
  108. <entry>integer</entry>
  109. <entry>int</entry>
  110. </row>
  111. <row>
  112. <entry>Zend_Crypt_Math_BigInteger</entry>
  113. <entry>i8</entry>
  114. </row>
  115. <row>
  116. <entry>double</entry>
  117. <entry>double</entry>
  118. </row>
  119. <row>
  120. <entry>boolean</entry>
  121. <entry>boolean</entry>
  122. </row>
  123. <row>
  124. <entry>string</entry>
  125. <entry>string</entry>
  126. </row>
  127. <row>
  128. <entry>null</entry>
  129. <entry>nil</entry>
  130. </row>
  131. <row>
  132. <entry>array</entry>
  133. <entry>array</entry>
  134. </row>
  135. <row>
  136. <entry>associative array</entry>
  137. <entry>struct</entry>
  138. </row>
  139. <row>
  140. <entry>object</entry>
  141. <entry>array</entry>
  142. </row>
  143. </tbody>
  144. </tgroup>
  145. </table>
  146. <note>
  147. <title>What type do empty arrays get cast to?</title>
  148. <para>
  149. Passing an empty array to an <acronym>XML-RPC</acronym> method is problematic,
  150. as it could represent either an array or a struct.
  151. <classname>Zend_XmlRpc_Client</classname> detects such conditions and
  152. makes a request to the server's
  153. <code>system.methodSignature</code> method to determine the
  154. appropriate <acronym>XML-RPC</acronym> type to cast to.
  155. </para>
  156. <para>
  157. However, this in itself can lead to issues. First off,
  158. servers that do not support
  159. <code>system.methodSignature</code> will log failed
  160. requests, and <classname>Zend_XmlRpc_Client</classname> will resort to
  161. casting the value to an <acronym>XML-RPC</acronym> array type. Additionally,
  162. this means that any call with array arguments will result in
  163. an additional call to the remote server.
  164. </para>
  165. <para>
  166. To disable the lookup entirely, you can call the
  167. <methodname>setSkipSystemLookup()</methodname> method prior to making
  168. your <acronym>XML-RPC</acronym> call:
  169. </para>
  170. <programlisting language="php"><![CDATA[
  171. $client->setSkipSystemLookup(true);
  172. $result = $client->call('foo.bar', array(array()));
  173. ]]></programlisting>
  174. </note>
  175. </sect3>
  176. <sect3 id="zend.xmlrpc.value.parameters.xmlrpc-value">
  177. <title>Zend_XmlRpc_Value Objects as Parameters</title>
  178. <para>
  179. Parameters may also be created as <classname>Zend_XmlRpc_Value</classname>
  180. instances to specify an exact <acronym>XML-RPC</acronym> type. The primary reasons
  181. for doing this are:
  182. <itemizedlist>
  183. <listitem>
  184. <para>
  185. When you want to make sure the correct parameter
  186. type is passed to the procedure (i.e. the
  187. procedure requires an integer and you may get it
  188. from a database as a string)
  189. </para>
  190. </listitem>
  191. <listitem>
  192. <para>
  193. When the procedure requires <code>base64</code> or
  194. <code>dateTime.iso8601</code> type (which doesn't exists as a
  195. <acronym>PHP</acronym> native type)
  196. </para>
  197. </listitem>
  198. <listitem>
  199. <para>
  200. When auto-conversion may fail (i.e. you want to
  201. pass an empty <acronym>XML-RPC</acronym> struct as a parameter. Empty
  202. structs are represented as empty arrays in <acronym>PHP</acronym>
  203. but, if you give an empty array as a parameter it
  204. will be auto-converted to an <acronym>XML-RPC</acronym> array since
  205. it's not an associative array)
  206. </para>
  207. </listitem>
  208. </itemizedlist>
  209. </para>
  210. <para>
  211. There are two ways to create a <classname>Zend_XmlRpc_Value</classname>
  212. object: instantiate one of the <classname>Zend_XmlRpc_Value</classname>
  213. subclasses directly, or use the static factory method
  214. <methodname>Zend_XmlRpc_Value::getXmlRpcValue()</methodname>.
  215. </para>
  216. <table id="zend.xmlrpc.value.parameters.xmlrpc-value.table-1">
  217. <title>Zend_XmlRpc_Value Objects for XML-RPC Types</title>
  218. <tgroup cols="3">
  219. <thead>
  220. <row>
  221. <entry><acronym>XML-RPC</acronym> Type</entry>
  222. <entry><classname>Zend_XmlRpc_Value</classname> Constant</entry>
  223. <entry><classname>Zend_XmlRpc_Value</classname> Object</entry>
  224. </row>
  225. </thead>
  226. <tbody>
  227. <row>
  228. <entry>int</entry>
  229. <entry>
  230. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_INTEGER</constant>
  231. </entry>
  232. <entry><classname>Zend_XmlRpc_Value_Integer</classname></entry>
  233. </row>
  234. <row>
  235. <entry>i8</entry>
  236. <entry>
  237. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_I8</constant>
  238. </entry>
  239. <entry><classname>Zend_XmlRpc_Value_BigInteger</classname></entry>
  240. </row>
  241. <row>
  242. <entry>ex:i8</entry>
  243. <entry>
  244. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_APACHEI8</constant>
  245. </entry>
  246. <entry><classname>Zend_XmlRpc_Value_BigInteger</classname></entry>
  247. </row>
  248. <row>
  249. <entry>double</entry>
  250. <entry>
  251. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_DOUBLE</constant>
  252. </entry>
  253. <entry><classname>Zend_XmlRpc_Value_Double</classname></entry>
  254. </row>
  255. <row>
  256. <entry>boolean</entry>
  257. <entry>
  258. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_BOOLEAN</constant>
  259. </entry>
  260. <entry><classname>Zend_XmlRpc_Value_Boolean</classname></entry>
  261. </row>
  262. <row>
  263. <entry>string</entry>
  264. <entry>
  265. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_STRING</constant>
  266. </entry>
  267. <entry><classname>Zend_XmlRpc_Value_String</classname></entry>
  268. </row>
  269. <row>
  270. <entry>nil</entry>
  271. <entry>
  272. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_NIL</constant>
  273. </entry>
  274. <entry><classname>Zend_XmlRpc_Value_Nil</classname></entry>
  275. </row>
  276. <row>
  277. <entry>ex:nil</entry>
  278. <entry>
  279. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_APACHENIL</constant>
  280. </entry>
  281. <entry><classname>Zend_XmlRpc_Value_Nil</classname></entry>
  282. </row>
  283. <row>
  284. <entry>base64</entry>
  285. <entry>
  286. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_BASE64</constant>
  287. </entry>
  288. <entry><classname>Zend_XmlRpc_Value_Base64</classname></entry>
  289. </row>
  290. <row>
  291. <entry>dateTime.iso8601</entry>
  292. <entry>
  293. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME</constant>
  294. </entry>
  295. <entry><classname>Zend_XmlRpc_Value_DateTime</classname></entry>
  296. </row>
  297. <row>
  298. <entry>array</entry>
  299. <entry>
  300. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_ARRAY</constant>
  301. </entry>
  302. <entry><classname>Zend_XmlRpc_Value_Array</classname></entry>
  303. </row>
  304. <row>
  305. <entry>struct</entry>
  306. <entry>
  307. <constant>Zend_XmlRpc_Value::XMLRPC_TYPE_STRUCT</constant>
  308. </entry>
  309. <entry><classname>Zend_XmlRpc_Value_Struct</classname></entry>
  310. </row>
  311. </tbody>
  312. </tgroup>
  313. </table>
  314. <para>
  315. <note>
  316. <title>Automatic Conversion</title>
  317. <para>
  318. When building a new <classname>Zend_XmlRpc_Value</classname>
  319. object, its value is set by a <acronym>PHP</acronym> type. The
  320. <acronym>PHP</acronym> type will be converted to the specified type using
  321. <acronym>PHP</acronym> casting. For example, if a string is given as a
  322. value to the <classname>Zend_XmlRpc_Value_Integer</classname>
  323. object, it will be converted using
  324. <code>(int)$value</code>.
  325. </para>
  326. </note>
  327. </para>
  328. </sect3>
  329. </sect2>
  330. <sect2 id="zend.xmlrpc.client.requests-and-responses">
  331. <title>Server Proxy Object</title>
  332. <para>
  333. Another way to call remote methods with the <acronym>XML-RPC</acronym> client is to
  334. use the server proxy. This is a <acronym>PHP</acronym> object that proxies a remote
  335. <acronym>XML-RPC</acronym> namespace, making it work as close to a native
  336. <acronym>PHP</acronym> object as possible.
  337. </para>
  338. <para>
  339. To instantiate a server proxy, call the <methodname>getProxy()</methodname>
  340. instance method of <classname>Zend_XmlRpc_Client</classname>. This will
  341. return an instance of <classname>Zend_XmlRpc_Client_ServerProxy</classname>.
  342. Any method call on the server proxy object will be forwarded to
  343. the remote, and parameters may be passed like any other <acronym>PHP</acronym>
  344. method.
  345. </para>
  346. <example id="zend.xmlrpc.client.requests-and-responses.example-1">
  347. <title>Proxy the Default Namespace</title>
  348. <programlisting language="php"><![CDATA[
  349. $client = new Zend_XmlRpc_Client('http://framework.zend.com/xmlrpc');
  350. $server = $client->getProxy(); // Proxy the default namespace
  351. $hello = $server->test->sayHello(1, 2); // test.Hello(1, 2) returns "hello"
  352. ]]></programlisting>
  353. </example>
  354. <para>
  355. The <methodname>getProxy()</methodname> method receives an optional argument
  356. specifying which namespace of the remote server to proxy. If it
  357. does not receive a namespace, the default namespace will be
  358. proxied. In the next example, the <code>test</code> namespace
  359. will be proxied:
  360. </para>
  361. <example id="zend.xmlrpc.client.requests-and-responses.example-2">
  362. <title>Proxy Any Namespace</title>
  363. <programlisting language="php"><![CDATA[
  364. $client = new Zend_XmlRpc_Client('http://framework.zend.com/xmlrpc');
  365. $test = $client->getProxy('test'); // Proxy the "test" namespace
  366. $hello = $test->sayHello(1, 2); // test.Hello(1,2) returns "hello"
  367. ]]></programlisting>
  368. </example>
  369. <para>
  370. If the remote server supports nested namespaces of any depth,
  371. these can also be used through the server proxy. For example, if
  372. the server in the example above had a method
  373. <code>test.foo.bar()</code>, it could be called as
  374. <code>$test->foo->bar()</code>.
  375. </para>
  376. </sect2>
  377. <sect2 id="zend.xmlrpc.client.error-handling">
  378. <title>Error Handling</title>
  379. <para>
  380. Two kinds of errors can occur during an <acronym>XML-RPC</acronym> method call:
  381. <acronym>HTTP</acronym> errors and <acronym>XML-RPC</acronym> faults. The
  382. <classname>Zend_XmlRpc_Client</classname> recognizes each and provides the ability
  383. to detect and trap them independently.
  384. </para>
  385. <sect3 id="zend.xmlrpc.client.error-handling.http">
  386. <title>HTTP Errors</title>
  387. <para>
  388. If any <acronym>HTTP</acronym> error occurs, such as the remote
  389. <acronym>HTTP</acronym> server returns a <code>404 Not Found</code>, a
  390. <classname>Zend_XmlRpc_Client_HttpException</classname> will be thrown.
  391. </para>
  392. <example id="zend.xmlrpc.client.error-handling.http.example-1">
  393. <title>Handling HTTP Errors</title>
  394. <programlisting language="php"><![CDATA[
  395. $client = new Zend_XmlRpc_Client('http://foo/404');
  396. try {
  397. $client->call('bar', array($arg1, $arg2));
  398. } catch (Zend_XmlRpc_Client_HttpException $e) {
  399. // $e->getCode() returns 404
  400. // $e->getMessage() returns "Not Found"
  401. }
  402. ]]></programlisting>
  403. </example>
  404. <para>
  405. Regardless of how the <acronym>XML-RPC</acronym> client is used, the
  406. <classname>Zend_XmlRpc_Client_HttpException</classname> will be thrown
  407. whenever an <acronym>HTTP</acronym> error occurs.
  408. </para>
  409. </sect3>
  410. <sect3 id="zend.xmlrpc.client.error-handling.faults">
  411. <title>XML-RPC Faults</title>
  412. <para>
  413. An <acronym>XML-RPC</acronym> fault is analogous to a <acronym>PHP</acronym>
  414. exception. It is a special type returned from an <acronym>XML-RPC</acronym> method
  415. call that has both an error code and an error message. <acronym>XML-RPC</acronym>
  416. faults are handled differently depending on the context of how the
  417. <classname>Zend_XmlRpc_Client</classname> is used.
  418. </para>
  419. <para>
  420. When the <methodname>call()</methodname> method or the server
  421. proxy object is used, an <acronym>XML-RPC</acronym> fault will result in a
  422. <classname>Zend_XmlRpc_Client_FaultException</classname> being thrown.
  423. The code and message of the exception will map directly to
  424. their respective values in the original <acronym>XML-RPC</acronym> fault
  425. response.
  426. </para>
  427. <example id="zend.xmlrpc.client.error-handling.faults.example-1">
  428. <title>Handling XML-RPC Faults</title>
  429. <programlisting language="php"><![CDATA[
  430. $client = new Zend_XmlRpc_Client('http://framework.zend.com/xmlrpc');
  431. try {
  432. $client->call('badMethod');
  433. } catch (Zend_XmlRpc_Client_FaultException $e) {
  434. // $e->getCode() returns 1
  435. // $e->getMessage() returns "Unknown method"
  436. }
  437. ]]></programlisting>
  438. </example>
  439. <para>
  440. When the <methodname>call()</methodname> method is used to make the
  441. request, the <classname>Zend_XmlRpc_Client_FaultException</classname> will be
  442. thrown on fault. A <classname>Zend_XmlRpc_Response</classname> object
  443. containing the fault will also be available by calling
  444. <methodname>getLastResponse()</methodname>.
  445. </para>
  446. <para>
  447. When the <methodname>doRequest()</methodname> method is used to make the
  448. request, it will not throw the exception. Instead, it will
  449. return a <classname>Zend_XmlRpc_Response</classname> object returned
  450. will containing the fault. This can be checked with
  451. <methodname>isFault()</methodname> instance method of
  452. <classname>Zend_XmlRpc_Response</classname>.
  453. </para>
  454. </sect3>
  455. </sect2>
  456. <sect2 id="zend.xmlrpc.client.introspection">
  457. <title>Server Introspection</title>
  458. <para>
  459. Some <acronym>XML-RPC</acronym> servers support the de facto introspection methods
  460. under the <acronym>XML-RPC</acronym> <code>system.</code> namespace.
  461. <classname>Zend_XmlRpc_Client</classname> provides special support for servers with
  462. these capabilities.
  463. </para>
  464. <para>
  465. A <classname>Zend_XmlRpc_Client_ServerIntrospection</classname> instance may be
  466. retrieved by calling the <methodname>getIntrospector()</methodname> method of
  467. <classname>Zend_XmlRpcClient</classname>. It can then be used to perform introspection
  468. operations on the server.
  469. </para>
  470. </sect2>
  471. <sect2 id="zend.xmlrpc.client.request-to-response">
  472. <title>From Request to Response</title>
  473. <para>
  474. Under the hood, the <methodname>call()</methodname> instance method of
  475. <classname>Zend_XmlRpc_Client</classname> builds a request object
  476. (<classname>Zend_XmlRpc_Request</classname>) and sends it to another method,
  477. <methodname>doRequest()</methodname>, that returns a response object
  478. (<classname>Zend_XmlRpc_Response</classname>).
  479. </para>
  480. <para>
  481. The <methodname>doRequest()</methodname> method is also available for use directly:
  482. </para>
  483. <example id="zend.xmlrpc.client.request-to-response.example-1">
  484. <title>Processing Request to Response</title>
  485. <programlisting language="php"><![CDATA[
  486. $client = new Zend_XmlRpc_Client('http://framework.zend.com/xmlrpc');
  487. $request = new Zend_XmlRpc_Request();
  488. $request->setMethod('test.sayHello');
  489. $request->setParams(array('foo', 'bar'));
  490. $client->doRequest($request);
  491. // $server->getLastRequest() returns instanceof Zend_XmlRpc_Request
  492. // $server->getLastResponse() returns instanceof Zend_XmlRpc_Response
  493. ]]></programlisting>
  494. </example>
  495. <para>
  496. Whenever an <acronym>XML-RPC</acronym> method call is made by the client through any
  497. means, either the <methodname>call()</methodname> method,
  498. <methodname>doRequest()</methodname> method, or server proxy, the last request
  499. object and its resultant response object will always be available
  500. through the methods <methodname>getLastRequest()</methodname> and
  501. <methodname>getLastResponse()</methodname> respectively.
  502. </para>
  503. </sect2>
  504. <sect2 id="zend.xmlrpc.client.http-client">
  505. <title>HTTP Client and Testing</title>
  506. <para>
  507. In all of the prior examples, an <acronym>HTTP</acronym> client was never specified.
  508. When this is the case, a new instance of
  509. <classname>Zend_Http_Client</classname> will be created with its default
  510. options and used by <classname>Zend_XmlRpc_Client</classname> automatically.
  511. </para>
  512. <para>
  513. The <acronym>HTTP</acronym> client can be retrieved at any time with the
  514. <methodname>getHttpClient()</methodname> method. For most cases, the default
  515. <acronym>HTTP</acronym> client will be sufficient. However, the
  516. <methodname>setHttpClient()</methodname> method allows for a different <acronym>HTTP</acronym>
  517. client instance to be injected.
  518. </para>
  519. <para>
  520. The <methodname>setHttpClient()</methodname> is particularly useful for unit testing. When combined
  521. with the <classname>Zend_Http_Client_Adapter_Test</classname>, remote services can be
  522. mocked out for testing. See the unit tests for <classname>Zend_XmlRpc_Client</classname>
  523. for examples of how to do this.
  524. </para>
  525. </sect2>
  526. </sect1>
  527. <!--
  528. vim:se ts=4 sw=4 et:
  529. -->