Zend_Soap_Wsdl.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 15617 -->
  4. <sect1 id="zend.soap.wsdl">
  5. <title>WSDLアクセッサ</title>
  6. <note>
  7. <para>
  8. WSDL文書による操作を行なうために、
  9. 内部的にZend_Soap_Serverコンポーネントによって<classname>Zend_Soap_Wsdl</classname>が使われます。
  10. それでも、このクラスにより提供される機能を独自の必要性によって使うこともできます。
  11. Zend_Soap_Wsdlパッケージは、パーサーとWSDL文書のビルダーを含みます。
  12. </para>
  13. <para>
  14. あなたに使う予定がなければ、この節を読み飛ばすことができます。
  15. </para>
  16. </note>
  17. <sect2 id="zend.soap.wsdl.constructor">
  18. <title>Zend_Soap_Wsdlコンストラクタ</title>
  19. <para>
  20. <classname>Zend_Soap_Wsdl</classname>コンストラクタは3つのパラメータをとります:
  21. <orderedlist>
  22. <listitem>
  23. <simpara><code>$name</code> - 記述されたウェブサービスの名前。</simpara>
  24. </listitem>
  25. <listitem>
  26. <simpara>
  27. <code>$uri</code> - WSDLが利用できるURI
  28. (ファイルシステムのファイルへのリファレンスでも可)
  29. </simpara>
  30. </listitem>
  31. <listitem>
  32. <simpara>
  33. <code>$strategy</code> - 複雑な型(オブジェクト)を検出する方策を
  34. 識別するために用いられるオプションのフラグです。
  35. これはバージョン1.7以前はブール値 <code>$extractComplexTypes</code>でしたが、
  36. 後方互換性のためにまだブール値として設定できます。
  37. デフォルトで、1.6の検出動作が設定されます。
  38. 複雑な型の検出の方策について詳しくは、この節をご覧下さい:
  39. <xref linkend="zend.soap.wsdl.types.add_complex" />
  40. </simpara>
  41. </listitem>
  42. </orderedlist>
  43. </para>
  44. </sect2>
  45. <sect2 id="zend.soap.wsdl.addmessage">
  46. <title>addMessage()メソッド</title>
  47. <para>
  48. <code>addMessage($name, $parts)</code>メソッドは、新しいメッセージの説明をWSDL文書に加えます。
  49. (/definitions/message 要素)
  50. </para>
  51. <para>
  52. <classname>Zend_Soap_Server</classname>および<classname>Zend_Soap_Client</classname>の機能に関して、
  53. 各々のメッセージはメソッドと対応します。
  54. </para>
  55. <para>
  56. <code>$name</code>パラメータはメッセージの名前を示します。
  57. </para>
  58. <para>
  59. <code>$parts</code>パラメータはSOAP呼び出しパラメータを表すメッセージ部分の配列です。
  60. それは連想配列です: 'part name' (SOAP呼び出しパラメータ名) =&gt; 'part type'.
  61. </para>
  62. <para>
  63. 型マッピングの管理は<code>addTypes()</code>や<code>addTypes()</code>、
  64. および<code>addComplexType()</code>メソッド(下記参照)を用いて実行されます。
  65. </para>
  66. <note>
  67. <para>
  68. メッセージ部分は 'element' または 'type' 属性を型決定のために使います。
  69. (<ulink url="http://www.w3.org/TR/wsdl#_messages"/>をご覧ください).
  70. </para>
  71. <para>
  72. 'element' 属性は、データ型定義の対応する要素を参照しなければなりません。
  73. 'type' 属性は、対応するcomplexType項目を参照します。
  74. </para>
  75. <para>
  76. 標準XSD型のすべてで 'element' および 'complexType' 定義の両方があります。
  77. (<ulink url="http://schemas.xmlsoap.org/soap/encoding/"/>参照)
  78. </para>
  79. <para>
  80. <classname>Zend_Soap_Wsdl::addComplexType()</classname>メソッドを用いて追加されるであろう、
  81. 標準ではない型のすべてがWSDL文書の '/definitions/types/schema/' セクションの 'complexType' ノードで記述されます。
  82. </para>
  83. <para>
  84. そして<code>addMessage()</code>メソッドは型を表現するために、
  85. 常に 'type' 属性を使います。
  86. </para>
  87. </note>
  88. </sect2>
  89. <sect2 id="zend.soap.wsdl.add_port_type">
  90. <title>addPortType()メソッド</title>
  91. <para>
  92. <code>addPortType($name)</code>メソッドは指定されたポートタイプ名で
  93. WSDL文書 (/definitions/portType) に新規のポートタイプを追加します。
  94. </para>
  95. <para>
  96. Zend_Soap_Server実行に関して定義されるウェブサービスメソッドのセットと結びつきます。
  97. </para>
  98. <para>
  99. 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_porttypes"/>をご覧ください。
  100. </para>
  101. </sect2>
  102. <sect2 id="zend.soap.wsdl.add_port_operation">
  103. <title>addPortOperation()メソッド</title>
  104. <para>
  105. <code>addPortOperation($portType, $name, $input = false, $output = false, $fault = false)</code>
  106. メソッドは、新しいポート・オペレーションをWSDL文書 (/definitions/portType/operation) の
  107. 指定されたポート・タイプに加えます。
  108. </para>
  109. <para>
  110. 各々のポート・オペレーションはZend_Soap_Server実行に関して、
  111. クラス・メソッド(ウェブサービスがクラスに基づくならば)
  112. または関数(ウェブサービスがメソッドセットに基づくならば)に対応します。
  113. </para>
  114. <para>
  115. それも、指定されたパラメータ、<code>$input</code>や<code>$output</code>および<code>$fault</code>に従って、
  116. 対応するポート・オペレーション・メッセージを加えます。
  117. <note>
  118. <para>
  119. <classname>Zend_Soap_Server</classname>クラスに基づいてサービスを記述するために、
  120. Zend_Soap_Serverコンポーネントは各々のポート・オペレーションのために2つのメッセージを生成します:
  121. <itemizedlist>
  122. <listitem>
  123. <para>
  124. <code>$methodName . 'Request'</code>という名前で入力メッセージ。
  125. </para>
  126. </listitem>
  127. <listitem>
  128. <para>
  129. <code>$methodName . 'Response'</code>という名前で出力メッセージ。
  130. </para>
  131. </listitem>
  132. </itemizedlist>
  133. </para>
  134. </note>
  135. </para>
  136. <para>
  137. 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_request-response"/>をご覧ください。
  138. </para>
  139. </sect2>
  140. <sect2 id="zend.soap.wsdl.add_binding">
  141. <title>addBinding()メソッド</title>
  142. <para>
  143. <code>addBinding($name, $portType)</code>メソッドは、新しいバインディングをWSDL文書 (/definitions/binding) に加えます。
  144. </para>
  145. <para>
  146. 'binding' WSDL文書ノードでは、
  147. メッセージ形式と特定のportTypeによって定義されるオペレーションとメッセージに関するプロトコル詳細を定義します。
  148. (<ulink url="http://www.w3.org/TR/wsdl#_bindings"/>をご覧ください)
  149. </para>
  150. <para>
  151. メソッドはバインディング・ノードをつくって、それを返します。
  152. それから、実際のデータで満たすために使われるかもしれません。
  153. </para>
  154. <para>
  155. Zend_Soap_Server実行ではWSDL文書の 'binding' 要素のために<code>$serviceName . 'Binding'</code> の名前が使われます。
  156. </para>
  157. </sect2>
  158. <sect2 id="zend.soap.wsdl.add_binding_operation">
  159. <title>addBindingOperation()メソッド</title>
  160. <para>
  161. <code>addBindingOperation($binding, $name, $input = false, $output = false, $fault = false)</code>
  162. メソッドはバインディング要素 (/definitions/binding/operation) に指定された名前で操作を追加します。
  163. </para>
  164. <para>
  165. It takes <code>XML_Tree_Node</code> object returned by <code>addBinding()</code> as an input
  166. (<code>$binding</code> parameter) to add 'operation' element with input/output/false entries depending on
  167. specified parameters
  168. </para>
  169. <para>
  170. Zend_Soap_Server implementation adds corresponding binding entry for each Web Service method with input and output
  171. entries defining 'soap:body' element as
  172. '&lt;soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
  173. </para>
  174. <para>
  175. 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_bindings"/>をご覧ください。
  176. </para>
  177. </sect2>
  178. <sect2 id="zend.soap.wsdl.add_soap_binding">
  179. <title>addSoapBinding()メソッド</title>
  180. <para>
  181. <code>addSoapBinding($binding, $style = 'document', $transport = 'http://schemas.xmlsoap.org/soap/http')</code>
  182. method adds SOAP binding ('soap:binding') entry to the binding element (which is already linked to some port type)
  183. with the specified style and transport (Zend_Soap_Server implementation uses RPC style over HTTP).
  184. </para>
  185. <para>
  186. '/definitions/binding/soap:binding' element is used to signify that the binding is bound to the SOAP protocol format.
  187. </para>
  188. <para>
  189. 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_bindings"/>をご覧ください。
  190. </para>
  191. </sect2>
  192. <sect2 id="zend.soap.wsdl.add_soap_operation">
  193. <title>addSoapOperation()メソッド</title>
  194. <para>
  195. <code>addSoapOperation($binding, $soap_action)</code>
  196. method adds SOAP operation ('soap:operation') entry to the binding element with the specified action.
  197. 'style' attribute of the 'soap:operation' element is not used since programming model (RPC-oriented or document-oriented)
  198. may be st using <code>addSoapBinding()</code> method
  199. </para>
  200. <para>
  201. 'soapAction' attribute of '/definitions/binding/soap:operation' element specifies the value of the SOAPAction header
  202. for this operation. This attribute is required for SOAP over HTTP and <emphasis>must not</emphasis> be
  203. specified for other transports.
  204. </para>
  205. <para>
  206. Zend_Soap_Server implementation uses <code>$serviceUri . '#' . $methodName</code> for SOAP operation action name.
  207. </para>
  208. <para>
  209. 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_soap:operation"/>をご覧ください。
  210. </para>
  211. </sect2>
  212. <sect2 id="zend.soap.wsdl.add_service">
  213. <title>addService()メソッド</title>
  214. <para>
  215. <code>addService($name, $port_name, $binding, $location)</code> method adds '/definitions/service' element to
  216. the WSDL document with the specified Wed Service name, port name, binding, and location.
  217. </para>
  218. <para>
  219. WSDL 1.1 allows to have several port types (sets of operations) per service. This ability is not used by
  220. Zend_Soap_Server implementation and not supported by <classname>Zend_Soap_Wsdl</classname> class.
  221. </para>
  222. <para>
  223. Zend_Soap_Server implementation uses:
  224. <itemizedlist>
  225. <listitem>
  226. <para>
  227. <code>$name . 'Service'</code> as a Web Service name,
  228. </para>
  229. </listitem>
  230. <listitem>
  231. <para>
  232. <code>$name . 'Port'</code> as a port type name,
  233. </para>
  234. </listitem>
  235. <listitem>
  236. <para>
  237. <code>'tns:' . $name . 'Binding'</code>
  238. <footnote>
  239. <para>
  240. <code>'tns:' namespace</code> is defined as script URI
  241. (<code>'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']</code>).
  242. </para>
  243. </footnote>
  244. as binding name,
  245. </para>
  246. </listitem>
  247. <listitem>
  248. <para>
  249. script URI<footnote><para><code>'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']</code></para></footnote>
  250. as a service URI for Web Service definition using classes.
  251. </para>
  252. </listitem>
  253. </itemizedlist>
  254. where <code>$name</code> is a class name for the Web Service definition mode using class and
  255. script name for the Web Service definition mode using set of functions.
  256. </para>
  257. <para>
  258. 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_services"/>をご覧ください。
  259. </para>
  260. </sect2>
  261. <sect2 id="zend.soap.wsdl.types">
  262. <title>型のマッピング</title>
  263. <para>
  264. Zend_Soap WSDL accessor implementation uses the following type mapping between PHP and SOAP types:
  265. <itemizedlist>
  266. <listitem>
  267. <para>PHP文字列 &lt;-&gt; <code>xsd:string</code></para>
  268. </listitem>
  269. <listitem>
  270. <para>PHP integer &lt;-&gt; <code>xsd:int</code></para>
  271. </listitem>
  272. <listitem>
  273. <para>PHP floatおよびdouble値 &lt;-&gt; <code>xsd:float</code></para>
  274. </listitem>
  275. <listitem>
  276. <para>PHPブール値 &lt;-&gt; <code>xsd:boolean</code></para>
  277. </listitem>
  278. <listitem>
  279. <para>PHP配列 &lt;-&gt; <code>soap-enc:Array</code></para>
  280. </listitem>
  281. <listitem>
  282. <para>PHPオブジェクト &lt;-&gt; <code>xsd:struct</code></para>
  283. </listitem>
  284. <listitem>
  285. <para>
  286. PHP class &lt;-&gt; based on complex type strategy (See: <xref linkend="zend.soap.wsdl.types.add_complex" />)
  287. <footnote>
  288. <para>
  289. By default <classname>Zend_Soap_Wsdl</classname> will be created with the <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>
  290. class as detection algorithm for complex types. The first parameter of the AutoDiscover constructor takes
  291. any complex type strategy implementing <classname>Zend_Soap_Wsdl_Strategy_Interface</classname> or a string with the name
  292. of the class. For backwards compatibility with <code>$extractComplexType</code> boolean variables are parsed
  293. the following way: If true, <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>, if false
  294. <classname>Zend_Soap_Wsdl_Strategy_AnyType</classname>.
  295. </para>
  296. </footnote>.
  297. </para>
  298. </listitem>
  299. <listitem>
  300. <para>PHP void &lt;-&gt; 空の型</para>
  301. </listitem>
  302. <listitem>
  303. <para>If type is not matched to any of these types by some reason, then <code>xsd:anyType</code> is used.</para>
  304. </listitem>
  305. </itemizedlist>
  306. Where <code>xsd:</code> is "http://www.w3.org/2001/XMLSchema" namespace,
  307. <code>soap-enc:</code> is a "http://schemas.xmlsoap.org/soap/encoding/" namespace,
  308. <code>tns:</code> is a "target namespace" for a service.
  309. </para>
  310. <sect3 id="zend.soap.wsdl.types.retrieve">
  311. <title>型情報の取得</title>
  312. <para>
  313. <code>getType($type)</code> method may be used to get mapping for a specified PHP type:
  314. <programlisting language="php"><![CDATA[
  315. ...
  316. $wsdl = new Zend_Soap_Wsdl('My_Web_Service', $myWebServiceUri);
  317. ...
  318. $soapIntType = $wsdl->getType('int');
  319. ...
  320. class MyClass {
  321. ...
  322. }
  323. ...
  324. $soapMyClassType = $wsdl->getType('MyClass');
  325. ]]></programlisting>
  326. </para>
  327. </sect3>
  328. <sect3 id="zend.soap.wsdl.types.add_complex">
  329. <title>複雑な型の情報を追加する</title>
  330. <para>
  331. <code>addComplexType($type)</code> method is used to add complex types (PHP classes) to a WSDL document.
  332. </para>
  333. <para>
  334. It's automatically used by <code>getType()</code> method to add corresponding complex types
  335. of method parameters or return types.
  336. </para>
  337. <para>
  338. Its detection and building algorithm is based on the currently
  339. active detection strategy for complex types. You can set the detection strategy either by
  340. specifying the class name as string or instance of a <classname>Zend_Soap_Wsdl_Strategy_Interface</classname>
  341. implementation as the third parameter of the constructor or using the <code>setComplexTypeStrategy($strategy)</code>
  342. function of Zend_Soap_Wsdl. The following detection strategies currently exist:
  343. </para>
  344. <itemizedlist>
  345. <listitem>
  346. <para>Class <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>: Enabled by default (when no
  347. third constructor parameter is set). Iterates over the public attributes of a class type and
  348. registers them as subtypes of the complex object type.</para>
  349. </listitem>
  350. <listitem>
  351. <para>Class <classname>Zend_Soap_Wsdl_Strategy_AnyType</classname>: Casts all complex types into the
  352. simple XSD type xsd:anyType. Be careful this shortcut for complex type detection can probably only
  353. be handled successfully by weakly typed languages such as PHP.
  354. </para>
  355. </listitem>
  356. <listitem>
  357. <para>Class <classname>Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence</classname>: This strategy allows
  358. to specify return parameters of the type: <code>int[]</code> or <code>string[]</code>. It can only
  359. handle simple PHP types such as int, string, boolean, float and so on, but allows to specify
  360. nested arrays of arrays of type.</para>
  361. </listitem>
  362. <listitem>
  363. <para>Class <classname>Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex</classname>: This strategy allows
  364. to detect very complex arrays of objects. Objects types are detected based on the
  365. <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname> and an array is wrapped
  366. around that definition.</para>
  367. </listitem>
  368. <listitem>
  369. <para>Class <classname>Zend_Soap_Wsdl_Strategy_Composite</classname>: This strategy can
  370. combine all strategies by connecting PHP Complex types (Classnames) to the desired strategy
  371. via the <code>connectTypeToStrategy($type, $strategy)</code> method. A complete typemap can be
  372. given to the constructor as an array with <code>$type</code> -> <code>$strategy</code> pairs.
  373. The second parameter specifies the default strategy that will be used if an unknown type is
  374. requested for adding. This parameter defaults to the <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>
  375. strategy.</para>
  376. </listitem>
  377. </itemizedlist>
  378. <para>
  379. <code>addComplexType()</code> method creates '/definitions/types/xsd:schema/xsd:complexType' element for
  380. each described complex type with name of the specified PHP class.
  381. </para>
  382. <para>
  383. Class property <emphasis>MUST</emphasis> have docblock section with the described PHP type to have property
  384. included into WSDL description.
  385. </para>
  386. <para>
  387. <code>addComplexType()</code> checks if type is already described within types section of the WSDL document.
  388. </para>
  389. <para>
  390. It prevents duplications if this method is called two or more times and recursion in the types definition
  391. section.
  392. </para>
  393. <para>
  394. 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_types"/>をご覧ください。
  395. </para>
  396. </sect3>
  397. </sect2>
  398. <sect2 id="zend.soap.wsdl.add_documentation">
  399. <title>addDocumentation()メソッド</title>
  400. <para>
  401. <code>addDocumentation($input_node, $documentation)</code> method adds human readable documentation using
  402. optional 'wsdl:document' element.
  403. </para>
  404. <para>
  405. '/definitions/binding/soap:binding' element is used to signify that the binding is bound to the SOAP protocol format.
  406. </para>
  407. <para>
  408. 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_documentation"/>をご覧ください。
  409. </para>
  410. </sect2>
  411. <sect2 id="zend.soap.wsdl.retrieve">
  412. <title>確定したWSDL文書を取得</title>
  413. <para>
  414. <code>toXML()</code>や<code>toDomDocument()</code>および<code>dump($filename = false)</code>メソッドは、
  415. WSDL文書をXMLやDOMの構造もしくはファイルとして取得するために使われるかもしれません。
  416. </para>
  417. </sect2>
  418. <sect2 id="zend.soap.wsdl.parser">
  419. <title>WSDL文書をパース</title>
  420. <para>
  421. Zend_Soap_WsdlはSOAPウェブサービス(クライアントとサーバー)をユニットテストおよびコード生成する際に、
  422. その主要なアプリケーションがあるWSDL文書のためのパーサーも有します。
  423. 下記にどのようにパーサーを使うか例を示します:
  424. </para>
  425. <programlisting language="php"><![CDATA[
  426. // WSDLをDOMDocumentに読み込み
  427. $dom = new DOMDocument();
  428. $dom->loadXML($wsdlString);
  429. // パーサ作成
  430. $parser = Zend_Soap_Wsdl_Parser::factory($dom);
  431. $result = $parser->parse();
  432. // ウェブサービス名
  433. echo $result->getName();
  434. // 接続ポートと内部要素
  435. foreach($result->ports AS $port) {
  436. echo $port->getName();
  437. foreach($port->bindings AS $binding) {
  438. echo $binding->getName();
  439. foreach($binding->operations AS $operation) {
  440. echo $operation->getName();
  441. echo $operation->inputMessage->getName();
  442. echo $operation->outputMessage->getName();
  443. }
  444. }
  445. }
  446. // あなたはバインディング、メッセージ、
  447. // 操作および他の要素に直接アクセスすることもできます。
  448. foreach($result->operations AS $operation) {
  449. // 処理
  450. }
  451. foreach($result->bindings AS $binding {
  452. // 処理
  453. }
  454. foreach($result->messages AS $message) {
  455. // 処理
  456. }
  457. foreach($result->services AS $service) {
  458. // 処理
  459. }
  460. foreach($result->types AS $type) {
  461. // 処理
  462. }
  463. ]]></programlisting>
  464. <para>
  465. それぞれの要素および文書を一意に識別する
  466. <code>getName()</code>および<code>getDocumentation()</code>関数を代理する
  467. インターフェース<classname>Zend_Soap_Wsdl_Element_Interface</classname>をすべての要素は実装します。
  468. すべての要素はより詳細な状態を示す public プロパティーを持ち、
  469. さらに簡単に反復してアクセスできる入れ子の依存関係も有します。
  470. </para>
  471. </sect2>
  472. </sect1>