| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect1 id="zend.soap.wsdl">
- <title>WSDL Accessor</title>
- <note>
- <para>
- <classname>Zend_Soap_Wsdl</classname> class is used by
- <classname>Zend_Soap_Server</classname> component internally to operate with WSDL
- documents. Nevertheless, you could also use functionality provided by this class for
- your own needs. The <classname>Zend_Soap_Wsdl</classname> package contains both a parser
- and a builder of WSDL documents.
- </para>
- <para>
- If you don't plan to do this, you can skip this documentation section.
- </para>
- </note>
- <sect2 id="zend.soap.wsdl.constructor">
- <title>Zend_Soap_Wsdl constructor</title>
- <para>
- <classname>Zend_Soap_Wsdl</classname> constructor takes three parameters:
- <orderedlist>
- <listitem>
- <simpara>
- <varname>$name</varname> - name of the Web Service being described.
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- <varname>$uri</varname> - <acronym>URI</acronym> where the WSDL will be
- available (could also be a reference to the file in the filesystem.)
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- <varname>$strategy</varname> - optional flag used to identify the strategy
- for complex types (objects) detection. This was a boolean
- <varname>$extractComplexTypes</varname> before version 1.7 and can still be
- set as a boolean for backwards compatibility. By default the 1.6 detection
- behaviour is set. To read more on complex type detection strategies go to
- the section: <link linkend="zend.soap.wsdl.types.add_complex">Add complex
- types</link>.
- </simpara>
- </listitem>
- </orderedlist>
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.addmessage">
- <title>addMessage() method</title>
- <para>
- <methodname>addMessage($name, $parts)</methodname> method adds new message description
- to the WSDL document (/definitions/message element).
- </para>
- <para>
- Each message correspond to methods in terms of <classname>Zend_Soap_Server</classname>
- and <classname>Zend_Soap_Client</classname> functionality.
- </para>
- <para>
- <varname>$name</varname> parameter represents message name.
- </para>
- <para>
- <varname>$parts</varname> parameter is an array of message parts which describe
- <acronym>SOAP</acronym> call parameters. It's an associative array: 'part name' (SOAP
- call parameter name) => 'part type'.
- </para>
- <para>
- Type mapping management is performed using <methodname>addTypes()</methodname>,
- <methodname>addTypes()</methodname> and <methodname>addComplexType()</methodname>
- methods (see below).
- </para>
- <note>
- <para>
- Messages parts can use either 'element' or 'type' attribute for typing
- (see <ulink url="http://www.w3.org/TR/wsdl#_messages"/>).
- </para>
- <para>
- 'element' attribute must refer to a corresponding element of data type definition.
- 'type' attribute refers to a corresponding complexType entry.
- </para>
- <para>
- All standard XSD types have both 'element' and 'complexType' definitions
- (see <ulink url="http://schemas.xmlsoap.org/soap/encoding/"/>).
- </para>
- <para>
- All non-standard types, which may be added using
- <methodname>Zend_Soap_Wsdl::addComplexType()</methodname> method, are described
- using 'complexType' node of '/definitions/types/schema/' section of WSDL document.
- </para>
- <para>
- So <methodname>addMessage()</methodname> method always uses 'type' attribute to
- describe types.
- </para>
- </note>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_port_type">
- <title>addPortType() method</title>
- <para>
- <methodname>addPortType($name)</methodname> method adds new port type to the WSDL
- document (/definitions/portType) with the specified port type name.
- </para>
- <para>
- It joins a set of Web Service methods defined in terms of
- <classname>Zend_Soap_Server</classname> implementation.
- </para>
- <para>
- See <ulink url="http://www.w3.org/TR/wsdl#_porttypes"/> for the details.
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_port_operation">
- <title>addPortOperation() method</title>
- <para>
- <methodname>addPortOperation($portType, $name, $input = false, $output = false, $fault
- = false)</methodname> method adds new port operation to the specified port type of
- the WSDL document (/definitions/portType/operation).
- </para>
- <para>
- Each port operation corresponds to a class method (if Web Service is based on a class)
- or function (if Web Service is based on a set of methods) in terms of
- <classname>Zend_Soap_Server</classname> implementation.
- </para>
- <para>
- It also adds corresponding port operation messages depending on specified
- <varname>$input</varname>, <varname>$output</varname> and <varname>$fault</varname>
- parameters.
- <note>
- <para>
- <classname>Zend_Soap_Server</classname> component generates two messages for
- each port operation while describing service based on
- <classname>Zend_Soap_Server</classname> class:
- <itemizedlist>
- <listitem>
- <para>
- input message with name <code>$methodName . 'Request'</code>.
- </para>
- </listitem>
- <listitem>
- <para>
- output message with name <code>$methodName . 'Response'</code>.
- </para>
- </listitem>
- </itemizedlist>
- </para>
- </note>
- </para>
- <para>
- See <ulink url="http://www.w3.org/TR/wsdl#_request-response"/> for the details.
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_binding">
- <title>addBinding() method</title>
- <para>
- <methodname>addBinding($name, $portType)</methodname> method adds new binding to the
- WSDL document (/definitions/binding).
- </para>
- <para>
- 'binding' WSDL document node defines message format and protocol details for operations
- and messages defined by a particular portType (see <ulink
- url="http://www.w3.org/TR/wsdl#_bindings"/>).
- </para>
- <para>
- The method creates binding node and returns it. Then it may be used to fill with actual
- data.
- </para>
- <para>
- <classname>Zend_Soap_Server</classname> implementation uses
- <code>$serviceName . 'Binding'</code> name for 'binding' element of WSDL document.
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_binding_operation">
- <title>addBindingOperation() method</title>
- <para>
- <methodname>addBindingOperation($binding, $name, $input = false, $output = false, $fault
- = false)</methodname> method adds an operation to a binding element
- (/definitions/binding/operation) with the specified name.
- </para>
- <para>
- It takes <code>XML_Tree_Node</code> object returned by
- <methodname>addBinding()</methodname> as an input (<varname>$binding</varname>
- parameter) to add 'operation' element with input/output/false entries depending on
- specified parameters
- </para>
- <para>
- <classname>Zend_Soap_Server</classname> 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>
- See <ulink url="http://www.w3.org/TR/wsdl#_bindings"/> for the details.
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_soap_binding">
- <title>addSoapBinding() method</title>
- <para>
- <methodname>addSoapBinding($binding, $style = 'document', $transport =
- 'http://schemas.xmlsoap.org/soap/http')</methodname> method adds
- <acronym>SOAP</acronym> 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 <acronym>HTTP</acronym>).
- </para>
- <para>
- '/definitions/binding/soap:binding' element is used to signify that the binding is bound
- to the <acronym>SOAP</acronym> protocol format.
- </para>
- <para>
- See <ulink url="http://www.w3.org/TR/wsdl#_bindings"/> for the details.
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_soap_operation">
- <title>addSoapOperation() method</title>
- <para>
- <methodname>addSoapOperation($binding, $soap_action)</methodname> method adds
- <acronym>SOAP</acronym> 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 using
- <methodname>addSoapBinding()</methodname> method
- </para>
- <para>
- 'soapAction' attribute of '/definitions/binding/soap:operation' element specifies the
- value of the <acronym>SOAP</acronym>Action header for this operation. This attribute is
- required for <acronym>SOAP</acronym> over <acronym>HTTP</acronym> and
- <emphasis>must not</emphasis> be specified for other transports.
- </para>
- <para>
- <classname>Zend_Soap_Server</classname> implementation uses
- <code>$serviceUri . '#' . $methodName</code> for <acronym>SOAP</acronym> operation
- action name.
- </para>
- <para>
- See <ulink url="http://www.w3.org/TR/wsdl#_soap:operation"/> for the details.
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_service">
- <title>addService() method</title>
- <para>
- <methodname>addService($name, $port_name, $binding, $location)</methodname> 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 <classname>Zend_Soap_Server</classname> implementation and not
- supported by <classname>Zend_Soap_Wsdl</classname> class.
- </para>
- <para>
- <classname>Zend_Soap_Server</classname> 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
- <acronym>URI</acronym> (<code>'http://' .$_SERVER['HTTP_HOST']
- . $_SERVER['SCRIPT_NAME']</code>).
- </para>
- </footnote>
- as binding name,
- </para>
- </listitem>
- <listitem>
- <para>
- script <acronym>URI</acronym>
- <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 <varname>$name</varname> 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>
- See <ulink url="http://www.w3.org/TR/wsdl#_services"/> for the details.
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.types">
- <title>Type mapping</title>
- <para>
- <classname>Zend_Soap</classname> WSDL accessor implementation uses the following type
- mapping between <acronym>PHP</acronym> and <acronym>SOAP</acronym> types:
- <itemizedlist>
- <listitem>
- <para>PHP strings <-> <code>xsd:string</code>.</para>
- </listitem>
- <listitem>
- <para>PHP integers <-> <code>xsd:int</code>.</para>
- </listitem>
- <listitem>
- <para>PHP floats and doubles <-> <code>xsd:float</code>.</para>
- </listitem>
- <listitem>
- <para>PHP booleans <-> <code>xsd:boolean</code>.</para>
- </listitem>
- <listitem>
- <para>PHP arrays <-> <code>soap-enc:Array</code>.</para>
- </listitem>
- <listitem>
- <para>PHP object <-> <code>xsd:struct</code>.</para>
- </listitem>
- <listitem>
- <para>
- <acronym>PHP</acronym> class <-> based on complex type strategy (See:
- <link linkend="zend.soap.wsdl.types.add_complex">this section</link>)
- <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
- <varname>$extractComplexType</varname> boolean variables are parsed
- the following way: If <constant>TRUE</constant>,
- <classname>Zend_Soap_Wsdl_Strategy_DefaultComplexType</classname>,
- if <constant>FALSE</constant>
- <classname>Zend_Soap_Wsdl_Strategy_AnyType</classname>.
- </para>
- </footnote>.
- </para>
- </listitem>
- <listitem>
- <para>PHP void <-> empty type.</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>Retrieving type information</title>
- <para>
- <methodname>getType($type)</methodname> method may be used to get mapping for a
- specified <acronym>PHP</acronym> type:
- </para>
- <programlisting language="php"><![CDATA[
- ...
- $wsdl = new Zend_Soap_Wsdl('My_Web_Service', $myWebServiceUri);
- ...
- $soapIntType = $wsdl->getType('int');
- ...
- class MyClass {
- ...
- }
- ...
- $soapMyClassType = $wsdl->getType('MyClass');
- ]]></programlisting>
- </sect3>
- <sect3 id="zend.soap.wsdl.types.add_complex">
- <title>Adding complex type information</title>
- <para>
- <methodname>addComplexType($type)</methodname> method is used to add complex types
- (PHP classes) to a WSDL document.
- </para>
- <para>
- It's automatically used by <methodname>getType()</methodname> 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
- <methodname>setComplexTypeStrategy($strategy)</methodname> function of
- <classname>Zend_Soap_Wsdl</classname>. 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 <acronym>PHP</acronym>.
- </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>. As of Zend Framework version
- 1.9 it can handle both simple <acronym>PHP</acronym> types such as int,
- string, boolean, float aswell as objects and arrays of objects.
- </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 <acronym>PHP</acronym>
- Complex types (Classnames) to the desired strategy via the
- <methodname>connectTypeToStrategy($type, $strategy)</methodname> method. A
- complete typemap can be given to the constructor as an array with
- <varname>$type</varname> -> <varname>$strategy</varname> 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>
- <methodname>addComplexType()</methodname> method creates
- '/definitions/types/xsd:schema/xsd:complexType' element for
- each described complex type with name of the specified <acronym>PHP</acronym> class.
- </para>
- <para>
- Class property <emphasis>MUST</emphasis> have docblock section with the described
- <acronym>PHP</acronym> type to have property included into WSDL description.
- </para>
- <para>
- <methodname>addComplexType()</methodname> 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>
- See <ulink url="http://www.w3.org/TR/wsdl#_types"/> for the details.
- </para>
- </sect3>
- </sect2>
- <sect2 id="zend.soap.wsdl.add_documentation">
- <title>addDocumentation() method</title>
- <para>
- <methodname>addDocumentation($input_node, $documentation)</methodname> 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 <acronym>SOAP</acronym> protocol format.
- </para>
- <para>
- See <ulink url="http://www.w3.org/TR/wsdl#_documentation"/> for the details.
- </para>
- </sect2>
- <sect2 id="zend.soap.wsdl.retrieve">
- <title>Get finalized WSDL document</title>
- <para>
- <methodname>toXML()</methodname>, <methodname>toDomDocument()</methodname> and
- <methodname>dump($filename = false)</methodname> methods may be used to get WSDL
- document as an <acronym>XML</acronym>, DOM structure or a file.
- </para>
- </sect2>
- </sect1>
|