Zend_Soap_Client.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 17173 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="zend.soap.client">
  5. <title>Zend_Soap_Client</title>
  6. <para>
  7. Die <classname>Zend_Soap_Client</classname> Klasse vereinfacht die Entwicklung von SOAP
  8. Clients für PHP Programmierern.
  9. </para>
  10. <para>
  11. Sie kann im WSDL oder im nicht-WSDL Modus verwendet werden.
  12. </para>
  13. <para>
  14. Im WSDL Modus verwendet die <classname>Zend_Soap_Client</classname> Komponente ein bereits
  15. vorbereitetes WSDL Dokument um die Optionen des Transport Layers zu definieren.
  16. </para>
  17. <para>
  18. Die WSDL Beschreibung wird normalerweise vom Web Service bereitgestellt auf das der Client
  19. zugreift. Wenn die WSDL Beschreibung nicht verfügbar gemacht wurde, kann man
  20. <classname>Zend_Soap_Client</classname> im nicht-WSDL Modus verwenden. In diesem Modus
  21. müssen alle SOAP Protokolloptionen explizit an der <classname>Zend_Soap_Client</classname>
  22. Klasse gesetzt werden.
  23. </para>
  24. <sect2 id="zend.soap.client.constructor">
  25. <title>Der Zend_Soap_Client Konstruktor</title>
  26. <para>
  27. Der <classname>Zend_Soap_Client</classname> Konstruktor nimmt zwei Parameter:
  28. <itemizedlist>
  29. <listitem>
  30. <para>
  31. <varname>$wsdl</varname> - eine URI einer WSDL Datei.
  32. </para>
  33. </listitem>
  34. <listitem>
  35. <para>
  36. <varname>$options</varname> - Optionen um ein SOAP Client Objekt zu
  37. erstellen.
  38. </para>
  39. </listitem>
  40. </itemizedlist>
  41. Beide Parameter können später gesetzt werden indem die
  42. <methodname>setWsdl($wsdl)</methodname> und
  43. <methodname>setOptions($options)</methodname> Methoden verwendet werden.
  44. </para>
  45. <note>
  46. <title>Wichtig!</title>
  47. <para>
  48. Wenn die <classname>Zend_Soap_Client</classname> Komponente im nicht-WSDL Modus
  49. verwendet wird, <emphasis>müssen</emphasis> die 'location' und 'uri' Optionen
  50. gesetzt werden.
  51. </para>
  52. </note>
  53. <para>
  54. Die folgenden Optionen werden erkannt:
  55. <itemizedlist>
  56. <listitem>
  57. <para>
  58. 'soap_version' ('soapVersion') - Die zu verwendende SOAP Version
  59. (SOAP_1_1 oder SOAP_1_2).
  60. </para>
  61. </listitem>
  62. <listitem>
  63. <para>
  64. 'classmap' ('classMap') welche verwendet werden kann um einige WSDL Typen
  65. auf PHP Klassen zu mappen.
  66. </para>
  67. <para>
  68. Die Option muß ein Array mit WSDL Typen als Schlüssel und Namen von PHP
  69. Klassen als Werte sein.
  70. </para>
  71. </listitem>
  72. <listitem>
  73. <para>
  74. 'encoding' - Interne Zeichen Kodierung (UTF-8 wird immer als externe
  75. Kodierung verwendet).
  76. </para>
  77. </listitem>
  78. <listitem>
  79. <para>
  80. 'wsdl' welcher dem Aufruf von <methodname>setWsdl($wsdlValue)</methodname>
  81. entspricht.
  82. </para>
  83. <para>
  84. Das Ändern dieser Option kann das <classname>Zend_Soap_Client</classname>
  85. Objekt von oder zum WSDL Modus wechseln.
  86. </para>
  87. </listitem>
  88. <listitem>
  89. <para>
  90. 'uri' - Der Ziel-Namespace für den SOAP Service (benötigt im nicht-WSDL
  91. Modus, funktioniert nicht im WSDL Modus).
  92. </para>
  93. </listitem>
  94. <listitem>
  95. <para>
  96. 'location' - Die URL der Anfrage (benötigt im nicht-WSDL Modus, funktioniert
  97. nicht im WSDL Modus).
  98. </para>
  99. </listitem>
  100. <listitem>
  101. <para>
  102. 'style' - Anfrage Stil (funktioniert nicht im WSDL Modus):
  103. <constant>SOAP_RPC</constant> oder <constant>SOAP_DOCUMENT</constant>.
  104. </para>
  105. </listitem>
  106. <listitem>
  107. <para>
  108. 'use' - Methode zum Verschlüsseln von Nachrichten (funktioniert nicht im
  109. WSDL Modus): <constant>SOAP_ENCODED</constant> oder
  110. <constant>SOAP_LITERAL</constant>.
  111. </para>
  112. </listitem>
  113. <listitem>
  114. <para>
  115. 'login' und 'password' - Login und Passwort für eine HTTP Authentifizierung.
  116. </para>
  117. </listitem>
  118. <listitem>
  119. <para>
  120. 'proxy_host', 'proxy_port', 'proxy_login', und 'proxy_password' - Eine HTTP
  121. Verbindung über einen Proxy Server.
  122. </para>
  123. </listitem>
  124. <listitem>
  125. <para>
  126. 'local_cert' und 'passphrase' - HTTPS Client Authentifizierungs Optionen für
  127. Zertifikate.
  128. </para>
  129. </listitem>
  130. <listitem>
  131. <para>
  132. 'compression' - Komprimierungs Optionen; das ist eine Kombination von
  133. <constant>SOAP_COMPRESSION_ACCEPT</constant>,
  134. <constant>SOAP_COMPRESSION_GZIP</constant> und
  135. <constant>SOAP_COMPRESSION_DEFLATE</constant> Optionen welche wie folgt
  136. verwendet werden können:
  137. <programlisting language="php"><![CDATA[
  138. // Komprimierung der Antworten akzeptieren
  139. $client = new Zend_Soap_Client("some.wsdl",
  140. array('compression' => SOAP_COMPRESSION_ACCEPT));
  141. ...
  142. // Anfragen komprimieren durch Verwendung von gzip mit Komprimierungs-Level 5
  143. $client = new Zend_Soap_Client("some.wsdl",
  144. array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5));
  145. ...
  146. // Anfragen komprimieren durch Verwendung der Deflate Komprimierung
  147. $client = new Zend_Soap_Client("some.wsdl",
  148. array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE));
  149. ]]></programlisting>
  150. </para>
  151. </listitem>
  152. </itemizedlist>
  153. </para>
  154. </sect2>
  155. <sect2 id="zend.soap.client.calls">
  156. <title>SOAP Anfragen durchführen</title>
  157. <para>
  158. Nachdem ein <classname>Zend_Soap_Client</classname> Objekt erstellt wurde sind wir
  159. bereit um SOAP Anfragen durchzuführen.
  160. </para>
  161. <para>
  162. Jede Methode des Web Services wird auf eine virtuelle
  163. <classname>Zend_Soap_Client</classname> Objekt-Methode gemappt welche Parameter mit
  164. üblichen PHP Typen entgegen nimmt.
  165. </para>
  166. <para>
  167. Es ist wie im folgenden Beispiel zu verwenden:
  168. <programlisting language="php"><![CDATA[
  169. //****************************************************************
  170. // Server Code
  171. //****************************************************************
  172. // class MyClass {
  173. // /**
  174. // * Diese Methode nimmt ...
  175. // *
  176. // * @param integer $inputParam
  177. // * @return string
  178. // */
  179. // public function method1($inputParam) {
  180. // ...
  181. // }
  182. //
  183. // /**
  184. // * Diese Methode nimmt ...
  185. // *
  186. // * @param integer $inputParam1
  187. // * @param string $inputParam2
  188. // * @return float
  189. // */
  190. // public function method2($inputParam1, $inputParam2) {
  191. // ...
  192. // }
  193. //
  194. // ...
  195. // }
  196. // ...
  197. // $server = new Zend_Soap_Server(null, $options);
  198. // $server->setClass('MyClass');
  199. // ...
  200. // $server->handle();
  201. //
  202. //****************************************************************
  203. // Ende des Server Codes
  204. //****************************************************************
  205. $client = new Zend_Soap_Client("MyService.wsdl");
  206. ...
  207. // $result1 ist ein String
  208. $result1 = $client->method1(10);
  209. ...
  210. // $result2 ist ein Float
  211. $result2 = $client->method2(22, 'irgendein String');
  212. ]]></programlisting>
  213. </para>
  214. </sect2>
  215. </sect1>