发布于 2015-10-07 09:54:43 | 114 次阅读 | 评论: 0 | 来源: 网络整理
注意 | |
---|---|
If you don't plan to do this, you can skip this documentation section. |
Zend_Soap_Wsdl
constructor takes three parameters:
$name
- name of the Web Service being described.$uri
- URI where the WSDL will be available
(could also be a reference to the file in the filesystem.)
$extractComplexTypes
- optional flag used to identify that complex types (objects)
should be extracted.
addMessage($name, $parts)
method adds new message description to the WSDL document
(/definitions/message element).
Each message correspond to methods in terms of Zend_Soap_Server
and
Zend_Soap_Client
functionality.
$name
parameter represents message name.
$parts
parameter is an array of message parts which describe SOAP call parameters.
It's an associative array: 'part name' (SOAP call parameter name) => 'part type'.
Type mapping management is performed using addTypes()
, addTypes()
and
addComplexType()
methods (see below).
注意 | |
---|---|
Messages parts can use either 'element' or 'type' attribute for typing (see http://www.w3.org/TR/wsdl#_messages). 'element' attribute must refer to a corresponding element of data type definition. 'type' attribute refers to a corresponding complexType entry. All standard XSD types have both 'element' and 'complexType' definitions (see http://schemas.xmlsoap.org/soap/encoding/).
All non-standard types, which may be added using
So |
addPortType($name)
method adds new port type to the WSDL document
(/definitions/portType) with the specified port type name.
It joins a set of Web Service methods defined in terms of Zend_Soap_Server implementation.
See http://www.w3.org/TR/wsdl#_porttypes for the details.
addPortOperation($portType, $name, $input = false, $output = false, $fault = false)
method
adds new port operation to the specified port type of the WSDL document
(/definitions/portType/operation).
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 Zend_Soap_Server implementation.
It also adds corresponding port operation messages depending on specified
$input
, $output
and $fault
parameters.
注意 | |
---|---|
Zend_Soap_Server component generates two messages for each port operation while describing service based on
|
See http://www.w3.org/TR/wsdl#_request-response for the details.
addBinding($name, $portType)
method adds new binding to the WSDL document (/definitions/binding).
'binding' WSDL document node defines message format and protocol details for operations and messages defined by a particular portType (see http://www.w3.org/TR/wsdl#_bindings).
The method creates binding node and returns it. Then it may be used to fill with actual data.
Zend_Soap_Server implementation uses $serviceName . 'Binding'
name for 'binding' element of WSDL document.
addBindingOperation($binding, $name, $input = false, $output = false, $fault = false)
method adds
an operation to a binding element (/definitions/binding/operation) with the specified name.
It takes XML_Tree_Node
object returned by addBinding()
as an input
($binding
parameter) to add 'operation' element with input/output/false entries depending on
specified parameters
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/"/>
See http://www.w3.org/TR/wsdl#_bindings for the details.
addSoapBinding($binding, $style = 'document', $transport = 'http://schemas.xmlsoap.org/soap/http')
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).
'/definitions/binding/soap:binding' element is used to signify that the binding is bound to the SOAP protocol format.
See http://www.w3.org/TR/wsdl#_bindings for the details.
addSoapOperation($binding, $soap_action)
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 addSoapBinding()
method
'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 must not be specified for other transports.
Zend_Soap_Server implementation uses $serviceUri . '#' . $methodName
for SOAP operation action name.
See http://www.w3.org/TR/wsdl#_soap:operation for the details.
addService($name, $port_name, $binding, $location)
method adds '/definitions/service' element to
the WSDL document with the specified Wed Service name, port name, binding, and location.
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 Zend_Soap_Wsdl
class.
Zend_Soap_Server implementation uses:
where $name
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.
See http://www.w3.org/TR/wsdl#_services for the details.
Zend_Soap WSDL accessor implementation uses the following type mapping between PHP and SOAP types:
PHP strings <-> xsd:string
.
PHP integers <-> xsd:int
.
PHP floats and doubles <-> xsd:float
.
PHP booleans <-> xsd:boolean
.
PHP arrays <-> soap-enc:Array
.
PHP object <-> xsd:struct
.
PHP class <-> tns:$className
[20].
PHP void <-> empty type.
If type is not matched to any of these types by some reason, then xsd:anyType
is used.
Where xsd:
is "http://www.w3.org/2001/XMLSchema" namespace,
soap-enc:
is a "http://schemas.xmlsoap.org/soap/encoding/" namespace,
tns:
is a "target namespace" for a service.
getType($type)
method may be used to get mapping for a specified PHP type:
... $wsdl = new Zend_Soap_Wsdl('My_Web_Service', $myWebServiceUri); ... $soapIntType = $wsdl->getType('int'); ... class MyClass { ... } ... $soapMyClassType = $wsdl->getType('MyClass');
addComplexType($type)
method is used to add complex types (PHP classes) to a WSDL document.
It's automatically used by getType()
method to add corresponding complex type
if $extractComplexTypes
parameter of the constructor is set to true
(otherwise classes are mapped to 'xsd:anyType' SOAP type).
addComplexType()
method creates '/definitions/types/xsd:schema/xsd:complexType' element for
each described complex type with name of the specified PHP class.
All class public properties are described as corresponding elements of 'xsd:all' node attached to 'xsd:complexType'.
Class property MUST have docblock section with the described PHP type to have property included into WSDL description.
addComplexType()
checks if type is already described within types section of the WSDL document.
It prevents duplications if this method is called two or more times and recursion in the types definition section.
See http://www.w3.org/TR/wsdl#_types for the details.
addDocumentation($input_node, $documentation)
method adds human readable documentation using
optional 'wsdl:document' element.
'/definitions/binding/soap:binding' element is used to signify that the binding is bound to the SOAP protocol format.
See http://www.w3.org/TR/wsdl#_documentation for the details.
toXML()
, toDomDocument()
and dump($filename = false)
methods may be used to get
WSDL document as an XML, DOM structure or a file.
[18]
'tns:' namespace
is defined as script URI
('http://' .$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']
).
[19] 'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']
[20]
If Zend_Soap_Wsdl
object is created with $extractComplexTypes
parameter turned off, then classes are translated to xsd:anyType
.
Otherwise, tns:$className
is used and type is described in details in <types>
WSDL section.