| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <!-- EN-Revision: 15617 -->
- <sect1 id="zend.soap.wsdl">
- <title>WSDLアクセッサ</title>
- <note>
- <para>
- WSDL文書による操作を行なうために、
- 内部的にZend_Soap_Serverコンポーネントによって<classname>Zend_Soap_Wsdl</classname>が使われます。
- それでも、このクラスにより提供される機能を独自の必要性によって使うこともできます。
- Zend_Soap_Wsdlパッケージは、パーサーとWSDL文書のビルダーを含みます。
- </para>
- <para>
- あなたに使う予定がなければ、この節を読み飛ばすことができます。
- </para>
- </note>
- <sect2 id="zend.soap.wsdl.constructor">
- <title>Zend_Soap_Wsdlコンストラクタ</title>
- <para>
- <classname>Zend_Soap_Wsdl</classname>コンストラクタは3つのパラメータをとります:
- <orderedlist>
- <listitem>
- <simpara><code>$name</code> - 記述されたウェブサービスの名前。</simpara>
- </listitem>
- <listitem>
- <simpara>
- <code>$uri</code> - WSDLが利用できるURI
- (ファイルシステムのファイルへのリファレンスでも可)
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- <code>$strategy</code> - 複雑な型(オブジェクト)を検出する方策を
- 識別するために用いられるオプションのフラグです。
- これはバージョン1.7以前はブール値 <code>$extractComplexTypes</code>でしたが、
- 後方互換性のためにまだブール値として設定できます。
- デフォルトで、1.6の検出動作が設定されます。
- 複雑な型の検出の方策について詳しくは、この節をご覧下さい:
- <xref linkend="zend.soap.wsdl.types.add_complex" />
- </simpara>
- </listitem>
- </orderedlist>
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.addmessage">
- <title>addMessage()メソッド</title>
- <para>
- <code>addMessage($name, $parts)</code>メソッドは、新しいメッセージの説明をWSDL文書に加えます。
- (/definitions/message 要素)
- </para>
- <para>
- <classname>Zend_Soap_Server</classname>および<classname>Zend_Soap_Client</classname>の機能に関して、
- 各々のメッセージはメソッドと対応します。
- </para>
- <para>
- <code>$name</code>パラメータはメッセージの名前を示します。
- </para>
- <para>
- <code>$parts</code>パラメータはSOAP呼び出しパラメータを表すメッセージ部分の配列です。
- それは連想配列です: 'part name' (SOAP呼び出しパラメータ名) => 'part type'.
- </para>
- <para>
- 型マッピングの管理は<code>addTypes()</code>や<code>addTypes()</code>、
- および<code>addComplexType()</code>メソッド(下記参照)を用いて実行されます。
- </para>
- <note>
- <para>
- メッセージ部分は 'element' または 'type' 属性を型決定のために使います。
- (<ulink url="http://www.w3.org/TR/wsdl#_messages"/>をご覧ください).
- </para>
- <para>
- 'element' 属性は、データ型定義の対応する要素を参照しなければなりません。
- 'type' 属性は、対応するcomplexType項目を参照します。
- </para>
- <para>
- 標準XSD型のすべてで 'element' および 'complexType' 定義の両方があります。
- (<ulink url="http://schemas.xmlsoap.org/soap/encoding/"/>参照)
- </para>
- <para>
- <classname>Zend_Soap_Wsdl::addComplexType()</classname>メソッドを用いて追加されるであろう、
- 標準ではない型のすべてがWSDL文書の '/definitions/types/schema/' セクションの 'complexType' ノードで記述されます。
- </para>
- <para>
- そして<code>addMessage()</code>メソッドは型を表現するために、
- 常に 'type' 属性を使います。
- </para>
- </note>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_port_type">
- <title>addPortType()メソッド</title>
- <para>
- <code>addPortType($name)</code>メソッドは指定されたポートタイプ名で
- WSDL文書 (/definitions/portType) に新規のポートタイプを追加します。
- </para>
- <para>
- Zend_Soap_Server実行に関して定義されるウェブサービスメソッドのセットと結びつきます。
- </para>
- <para>
- 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_porttypes"/>をご覧ください。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_port_operation">
- <title>addPortOperation()メソッド</title>
- <para>
- <code>addPortOperation($portType, $name, $input = false, $output = false, $fault = false)</code>
- メソッドは、新しいポート・オペレーションをWSDL文書 (/definitions/portType/operation) の
- 指定されたポート・タイプに加えます。
- </para>
- <para>
- 各々のポート・オペレーションはZend_Soap_Server実行に関して、
- クラス・メソッド(ウェブサービスがクラスに基づくならば)
- または関数(ウェブサービスがメソッドセットに基づくならば)に対応します。
- </para>
- <para>
- それも、指定されたパラメータ、<code>$input</code>や<code>$output</code>および<code>$fault</code>に従って、
- 対応するポート・オペレーション・メッセージを加えます。
- <note>
- <para>
- <classname>Zend_Soap_Server</classname>クラスに基づいてサービスを記述するために、
- Zend_Soap_Serverコンポーネントは各々のポート・オペレーションのために2つのメッセージを生成します:
- <itemizedlist>
- <listitem>
- <para>
- <code>$methodName . 'Request'</code>という名前で入力メッセージ。
- </para>
- </listitem>
- <listitem>
- <para>
- <code>$methodName . 'Response'</code>という名前で出力メッセージ。
- </para>
- </listitem>
- </itemizedlist>
- </para>
- </note>
- </para>
- <para>
- 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_request-response"/>をご覧ください。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_binding">
- <title>addBinding()メソッド</title>
- <para>
- <code>addBinding($name, $portType)</code>メソッドは、新しいバインディングをWSDL文書 (/definitions/binding) に加えます。
- </para>
- <para>
- 'binding' WSDL文書ノードでは、
- メッセージ形式と特定のportTypeによって定義されるオペレーションとメッセージに関するプロトコル詳細を定義します。
- (<ulink url="http://www.w3.org/TR/wsdl#_bindings"/>をご覧ください)
- </para>
- <para>
- メソッドはバインディング・ノードをつくって、それを返します。
- それから、実際のデータで満たすために使われるかもしれません。
- </para>
- <para>
- Zend_Soap_Server実行ではWSDL文書の 'binding' 要素のために<code>$serviceName . 'Binding'</code> の名前が使われます。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_binding_operation">
- <title>addBindingOperation()メソッド</title>
- <para>
- <code>addBindingOperation($binding, $name, $input = false, $output = false, $fault = false)</code>
- メソッドはバインディング要素 (/definitions/binding/operation) に指定された名前で操作を追加します。
- </para>
- <para>
- It takes <code>XML_Tree_Node</code> object returned by <code>addBinding()</code> as an input
- (<code>$binding</code> parameter) to add 'operation' element with input/output/false entries depending on
- specified parameters
- </para>
- <para>
- Zend_Soap_Server implementation adds corresponding binding entry for each Web Service method with input and output
- entries defining 'soap:body' element as
- '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
- </para>
- <para>
- 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_bindings"/>をご覧ください。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_soap_binding">
- <title>addSoapBinding()メソッド</title>
- <para>
- <code>addSoapBinding($binding, $style = 'document', $transport = 'http://schemas.xmlsoap.org/soap/http')</code>
- method adds SOAP binding ('soap:binding') entry to the binding element (which is already linked to some port type)
- with the specified style and transport (Zend_Soap_Server implementation uses RPC style over HTTP).
- </para>
- <para>
- '/definitions/binding/soap:binding' element is used to signify that the binding is bound to the SOAP protocol format.
- </para>
- <para>
- 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_bindings"/>をご覧ください。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_soap_operation">
- <title>addSoapOperation()メソッド</title>
- <para>
- <code>addSoapOperation($binding, $soap_action)</code>
- method adds SOAP operation ('soap:operation') entry to the binding element with the specified action.
- 'style' attribute of the 'soap:operation' element is not used since programming model (RPC-oriented or document-oriented)
- may be st using <code>addSoapBinding()</code> method
- </para>
- <para>
- 'soapAction' attribute of '/definitions/binding/soap:operation' element specifies the value of the SOAPAction header
- for this operation. This attribute is required for SOAP over HTTP and <emphasis>must not</emphasis> be
- specified for other transports.
- </para>
- <para>
- Zend_Soap_Server implementation uses <code>$serviceUri . '#' . $methodName</code> for SOAP operation action name.
- </para>
- <para>
- 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_soap:operation"/>をご覧ください。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_service">
- <title>addService()メソッド</title>
- <para>
- <code>addService($name, $port_name, $binding, $location)</code> method adds '/definitions/service' element to
- the WSDL document with the specified Wed Service name, port name, binding, and location.
- </para>
- <para>
- WSDL 1.1 allows to have several port types (sets of operations) per service. This ability is not used by
- Zend_Soap_Server implementation and not supported by <classname>Zend_Soap_Wsdl</classname> class.
- </para>
- <para>
- Zend_Soap_Server implementation uses:
- <itemizedlist>
- <listitem>
- <para>
- <code>$name . 'Service'</code> as a Web Service name,
- </para>
- </listitem>
- <listitem>
- <para>
- <code>$name . 'Port'</code> as a port type name,
- </para>
- </listitem>
- <listitem>
- <para>
- <code>'tns:' . $name . 'Binding'</code>
- <footnote>
- <para>
- <code>'tns:' namespace</code> is defined as script URI
- (<code>'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']</code>).
- </para>
- </footnote>
- as binding name,
- </para>
- </listitem>
- <listitem>
- <para>
- script URI<footnote><para><code>'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']</code></para></footnote>
- as a service URI for Web Service definition using classes.
- </para>
- </listitem>
- </itemizedlist>
- where <code>$name</code> is a class name for the Web Service definition mode using class and
- script name for the Web Service definition mode using set of functions.
- </para>
- <para>
- 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_services"/>をご覧ください。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.types">
- <title>型のマッピング</title>
- <para>
- Zend_Soap WSDL accessor implementation uses the following type mapping between PHP and SOAP types:
- <itemizedlist>
- <listitem>
- <para>PHP文字列 <-> <code>xsd:string</code></para>
- </listitem>
- <listitem>
- <para>PHP integer <-> <code>xsd:int</code></para>
- </listitem>
- <listitem>
- <para>PHP floatおよびdouble値 <-> <code>xsd:float</code></para>
- </listitem>
- <listitem>
- <para>PHPブール値 <-> <code>xsd:boolean</code></para>
- </listitem>
- <listitem>
- <para>PHP配列 <-> <code>soap-enc:Array</code></para>
- </listitem>
- <listitem>
- <para>PHPオブジェクト <-> <code>xsd:struct</code></para>
- </listitem>
- <listitem>
- <para>
- PHP class <-> based on complex type strategy (See: <xref linkend="zend.soap.wsdl.types.add_complex" />)
- <footnote>
- <para>
- By default <classname>Zend_Soap_Wsdl</classname> will be created with the <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>
- class as detection algorithm for complex types. The first parameter of the AutoDiscover constructor takes
- any complex type strategy implementing <classname>Zend_Soap_Wsdl_Strategy_Interface</classname> or a string with the name
- of the class. For backwards compatibility with <code>$extractComplexType</code> boolean variables are parsed
- the following way: If true, <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>, if false
- <classname>Zend_Soap_Wsdl_Strategy_AnyType</classname>.
- </para>
- </footnote>.
- </para>
- </listitem>
- <listitem>
- <para>PHP void <-> 空の型</para>
- </listitem>
- <listitem>
- <para>If type is not matched to any of these types by some reason, then <code>xsd:anyType</code> is used.</para>
- </listitem>
- </itemizedlist>
- Where <code>xsd:</code> is "http://www.w3.org/2001/XMLSchema" namespace,
- <code>soap-enc:</code> is a "http://schemas.xmlsoap.org/soap/encoding/" namespace,
- <code>tns:</code> is a "target namespace" for a service.
- </para>
- <sect3 id="zend.soap.wsdl.types.retrieve">
- <title>型情報の取得</title>
- <para>
- <code>getType($type)</code> method may be used to get mapping for a specified PHP type:
- <programlisting language="php"><![CDATA[
- ...
- $wsdl = new Zend_Soap_Wsdl('My_Web_Service', $myWebServiceUri);
- ...
- $soapIntType = $wsdl->getType('int');
- ...
- class MyClass {
- ...
- }
- ...
- $soapMyClassType = $wsdl->getType('MyClass');
- ]]></programlisting>
- </para>
- </sect3>
- <sect3 id="zend.soap.wsdl.types.add_complex">
- <title>複雑な型の情報を追加する</title>
- <para>
- <code>addComplexType($type)</code> method is used to add complex types (PHP classes) to a WSDL document.
- </para>
- <para>
- It's automatically used by <code>getType()</code> method to add corresponding complex types
- of method parameters or return types.
- </para>
- <para>
- Its detection and building algorithm is based on the currently
- active detection strategy for complex types. You can set the detection strategy either by
- specifying the class name as string or instance of a <classname>Zend_Soap_Wsdl_Strategy_Interface</classname>
- implementation as the third parameter of the constructor or using the <code>setComplexTypeStrategy($strategy)</code>
- function of Zend_Soap_Wsdl. The following detection strategies currently exist:
- </para>
- <itemizedlist>
- <listitem>
- <para>Class <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>: Enabled by default (when no
- third constructor parameter is set). Iterates over the public attributes of a class type and
- registers them as subtypes of the complex object type.</para>
- </listitem>
- <listitem>
- <para>Class <classname>Zend_Soap_Wsdl_Strategy_AnyType</classname>: Casts all complex types into the
- simple XSD type xsd:anyType. Be careful this shortcut for complex type detection can probably only
- be handled successfully by weakly typed languages such as PHP.
- </para>
- </listitem>
- <listitem>
- <para>Class <classname>Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence</classname>: This strategy allows
- to specify return parameters of the type: <code>int[]</code> or <code>string[]</code>. It can only
- handle simple PHP types such as int, string, boolean, float and so on, but allows to specify
- nested arrays of arrays of type.</para>
- </listitem>
- <listitem>
- <para>Class <classname>Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex</classname>: This strategy allows
- to detect very complex arrays of objects. Objects types are detected based on the
- <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname> and an array is wrapped
- around that definition.</para>
- </listitem>
- <listitem>
- <para>Class <classname>Zend_Soap_Wsdl_Strategy_Composite</classname>: This strategy can
- combine all strategies by connecting PHP Complex types (Classnames) to the desired strategy
- via the <code>connectTypeToStrategy($type, $strategy)</code> method. A complete typemap can be
- given to the constructor as an array with <code>$type</code> -> <code>$strategy</code> pairs.
- The second parameter specifies the default strategy that will be used if an unknown type is
- requested for adding. This parameter defaults to the <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>
- strategy.</para>
- </listitem>
- </itemizedlist>
- <para>
- <code>addComplexType()</code> method creates '/definitions/types/xsd:schema/xsd:complexType' element for
- each described complex type with name of the specified PHP class.
- </para>
- <para>
- Class property <emphasis>MUST</emphasis> have docblock section with the described PHP type to have property
- included into WSDL description.
- </para>
- <para>
- <code>addComplexType()</code> checks if type is already described within types section of the WSDL document.
- </para>
- <para>
- It prevents duplications if this method is called two or more times and recursion in the types definition
- section.
- </para>
- <para>
- 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_types"/>をご覧ください。
- </para>
- </sect3>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_documentation">
- <title>addDocumentation()メソッド</title>
- <para>
- <code>addDocumentation($input_node, $documentation)</code> method adds human readable documentation using
- optional 'wsdl:document' element.
- </para>
- <para>
- '/definitions/binding/soap:binding' element is used to signify that the binding is bound to the SOAP protocol format.
- </para>
- <para>
- 詳しくは<ulink url="http://www.w3.org/TR/wsdl#_documentation"/>をご覧ください。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.retrieve">
- <title>確定したWSDL文書を取得</title>
- <para>
- <code>toXML()</code>や<code>toDomDocument()</code>および<code>dump($filename = false)</code>メソッドは、
- WSDL文書をXMLやDOMの構造もしくはファイルとして取得するために使われるかもしれません。
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.parser">
- <title>WSDL文書をパース</title>
- <para>
- Zend_Soap_WsdlはSOAPウェブサービス(クライアントとサーバー)をユニットテストおよびコード生成する際に、
- その主要なアプリケーションがあるWSDL文書のためのパーサーも有します。
- 下記にどのようにパーサーを使うか例を示します:
- </para>
- <programlisting language="php"><![CDATA[
- // WSDLをDOMDocumentに読み込み
- $dom = new DOMDocument();
- $dom->loadXML($wsdlString);
- // パーサ作成
- $parser = Zend_Soap_Wsdl_Parser::factory($dom);
- $result = $parser->parse();
- // ウェブサービス名
- echo $result->getName();
- // 接続ポートと内部要素
- foreach($result->ports AS $port) {
- echo $port->getName();
- foreach($port->bindings AS $binding) {
- echo $binding->getName();
- foreach($binding->operations AS $operation) {
- echo $operation->getName();
- echo $operation->inputMessage->getName();
- echo $operation->outputMessage->getName();
- }
- }
- }
- // あなたはバインディング、メッセージ、
- // 操作および他の要素に直接アクセスすることもできます。
- foreach($result->operations AS $operation) {
- // 処理
- }
- foreach($result->bindings AS $binding {
- // 処理
- }
- foreach($result->messages AS $message) {
- // 処理
- }
- foreach($result->services AS $service) {
- // 処理
- }
- foreach($result->types AS $type) {
- // 処理
- }
- ]]></programlisting>
- <para>
- それぞれの要素および文書を一意に識別する
- <code>getName()</code>および<code>getDocumentation()</code>関数を代理する
- インターフェース<classname>Zend_Soap_Wsdl_Element_Interface</classname>をすべての要素は実装します。
- すべての要素はより詳細な状態を示す public プロパティーを持ち、
- さらに簡単に反復してアクセスできる入れ子の依存関係も有します。
- </para>
- </sect2>
- </sect1>
|