Previous Next

WSDL Accessor

Note:

Zend_Soap_Wsdl class is used by Zend_Soap_Server component internally to operate with WSDL documents. Nevertheless, you could also use functionality provided by this class for your own needs. The Zend_Soap_Wsdl package contains both a parser and a builder of WSDL documents.

If you don't plan to do this, you can skip this documentation section.

Zend_Soap_Wsdl constructor.

Zend_Soap_Wsdl constructor takes three parameters:

  1. $name - name of the Web Service being described.
  2. $uri - URI where the WSDL will be available (could also be a reference to the file in the filesystem.)
  3. $strategy - optional flag used to identify the strategy for complex types (objects) detection. This was a boolean $extractComplexTypes 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: Adding complex type information..

addMessage() method.

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).

Note:

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 Zend_Soap_Wsdl::addComplexType() method, are described using 'complexType' node of '/definitions/types/schema/' section of WSDL document.

So addMessage() method always uses 'type' attribute to describe types.

addPortType() method.

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() method.

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.

Note:

Zend_Soap_Server component generates two messages for each port operation while describing service based on Zend_Soap_Server class:

  • input message with name $methodName . 'Request'.

  • output message with name $methodName . 'Response'.

See http://www.w3.org/TR/wsdl#_request-response for the details.

addBinding() method.

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() method.

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() method.

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() method.

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() method.

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:

  • $name . 'Service' as a Web Service name,

  • $name . 'Port' as a port type name,

  • 'tns:' . $name . 'Binding' [1] 'tns:' namespace'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] as binding name,

  • script URI[2]'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] as a service URI for Web Service definition using classes.

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.

Type mapping.

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 <-> based on complex type strategy (See: Adding complex type information.) [3] Zend_Soap_WsdlZend_Soap_Wsdl_Strategy_DefaultComplexTypeZend_Soap_Wsdl_Strategy_Interface$extractComplexTypeZend_Soap_Wsdl_Strategy_DefaultComplexTypeZend_Soap_Wsdl_Strategy_AnyType .

  • 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.

Retrieving type information.

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');

Adding complex type information.

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 types of method parameters or return types.

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 Zend_Soap_Wsdl_Strategy_Interface implementation as the third parameter of the constructor or using the setComplexTypeStrategy($strategy) function of Zend_Soap_Wsdl. The following detection strategies currently exist:

  • Class Zend_Soap_Wsdl_Strategy_DefaultComplexType: 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.

  • Class Zend_Soap_Wsdl_Strategy_AnyType: 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.

  • Class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence: This strategy allows to specify return parameters of the type: int[] or string[]. 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.

  • Class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex: This strategy allows to detect very complex arrays of objects. Objects types are detected based on the Zend_Soap_Wsdl_Strategy_DefaultComplexType and an array is wrapped around that definition.

  • Class Zend_Soap_Wsdl_Strategy_Composite: This strategy can combine all strategies by connecting PHP Complex types (Classnames) to the desired strategy via the connectTypeToStrategy($type, $strategy) method. A complete typemap can be given to the constructor as an array with $type -> $strategy 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 Zend_Soap_Wsdl_Strategy_DefaultComplexType strategy.

addComplexType() method creates '/definitions/types/xsd:schema/xsd:complexType' element for each described complex type with name of the specified PHP class.

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() method.

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.

Get finalized WSDL document.

toXML(), toDomDocument() and dump($filename = false) methods may be used to get WSDL document as an XML, DOM structure or a file.

Parsing WSDL documents

Zend_Soap_Wsdl also contains a parser for WSDL documents that has its main application in unit-testing and code-generation for SOAP Webservices (Client and Server). The following example will show how the Parser can be used:

// Load WSDL into DOMDocument
$dom = new DOMDocument();
$dom->loadXML($wsdlString);

// Create parser
$parser = Zend_Soap_Wsdl_Parser::factory($dom);
$result = $parser->parse();

// Webservice Name
echo $result->getName();

// Access Ports and inner elements
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();
        }
    }
}
// You can access bindings, messages and operations
// and other elements directly too
foreach($result->operations AS $operation) {
    // do stuff
}
foreach($result->bindings AS $binding {
    // do stuff
}
foreach($result->messages AS $message) {
    // do stuff
}
foreach($result->services AS $service) {
    // do stuff
}
foreach($result->types AS $type) {
    // do stuff
}

All elements implement the interface Zend_Soap_Wsdl_Element_Interface that proxies a getName() and a getDocumentation() function with the unique identifier of the element and its documentation respectivly. All the elements have public properties that describe its state in more detail and also contain their nested dependencies for easy iteratable access.

[1] is defined as script URI ().
[3] By default will be created with the class as detection algorithm for complex types. The first parameter of the AutoDiscover constructor takes any complex type strategy implementing or a string with the name of the class. For backwards compatibility with boolean variables are parsed the following way: If true, , if false .
Previous Next
Introduction to Zend Framework
Overview
Installation
Zend_Acl
Introduction
Refining Access Controls
Advanced Usage
Zend_Amf
Introduction
Zend_Amf_Server
Zend_Application
Introduction
Zend_Application Quick Start
Theory of Operation
Examples
Core Functionality
Available Resource Plugins
Zend_Auth
Introduction
Database Table Authentication
Digest Authentication
HTTP Authentication Adapter
LDAP Authentication
Open ID Authentication
Zend_Cache
Introduction
The Theory of Caching
Zend_Cache Frontends
Zend_Cache Backends
Zend_Captcha
Introduction
Captcha Operation
CAPTCHA Adapters
Zend_CodeGenerator
Introduction
Zend_CodeGenerator Examples
Zend_CodeGenerator Reference
Zend_Config
Introduction
Theory of Operation
Zend_Config_Ini
Zend_Config_Xml
Zend_Config_Writer
Zend_Config_Writer
Zend_Console_Getopt
Introduction
Declaring Getopt Rules
Fetching Options and Arguments
Configuring Zend_Console_Getopt
Zend_Controller
Zend_Controller Quick Start
Zend_Controller Basics
The Front Controller
The Request Object
The Standard Router
The Dispatcher
Action Controllers
Action Helpers
The Response Object
Plugins
Using a Conventional Modular Directory Structure
MVC Exceptions
Migrating from Previous Versions
Zend_Currency
Introduction to Zend_Currency
How to Work with Currencies
Migrating from Previous Versions
Zend_Date
Introduction
Theory of Operation
Basic Methods
Zend_Date API Overview
Creation of Dates
Constants for General Date Functions
Working Examples
Zend_Db
Zend_Db_Adapter
Zend_Db_Statement
Zend_Db_Profiler
Zend_Db_Select
Zend_Db_Table
Zend_Db_Table_Row
Zend_Db_Table_Rowset
Zend_Db_Table Relationships
Zend_Debug
Dumping Variables
Zend_Dojo
Introduction
Zend_Dojo_Data: dojo.data Envelopes
Dojo View Helpers
Dojo Form Elements and Decorators
Zend_Dom
Introduction
Zend_Dom_Query
Zend_Exception
Using Exceptions
Zend_Feed
Introduction
Importing Feeds
Retrieving Feeds from Web Pages
Consuming an RSS Feed
Consuming an Atom Feed
Consuming a Single Atom Entry
Modifying Feed and Entry structures
Custom Feed and Entry Classes
Zend_File
Zend_File_Transfer
Validators for Zend_File_Transfer
Filters for Zend_File_Transfer
Migrating from previous versions
Zend_Filter
Introduction
Standard Filter Classes
Filter Chains
Writing Filters
Zend_Filter_Input
Zend_Filter_Inflector
Zend_Form
Zend_Form
Zend_Form Quick Start
Creating Form Elements Using Zend_Form_Element
Creating Forms Using Zend_Form
Creating Custom Form Markup Using Zend_Form_Decorator
Standard Form Elements Shipped With Zend Framework
Standard Form Decorators Shipped With Zend Framework
Internationalization of Zend_Form
Advanced Zend_Form Usage
Zend_Gdata
Introduction
Authenticating with AuthSub
Using the Book Search Data API
Authenticating with ClientLogin
Using Google Calendar
Using Google Documents List Data API
Using Google Health
Using Google Spreadsheets
Using Google Apps Provisioning
Using Google Base
Using Picasa Web Albums
Using the YouTube Data API
Catching Gdata Exceptions
Zend_Http
Introduction
Zend_Http_Client - Advanced Usage
Zend_Http_Client - Connection Adapters
Zend_Http_Cookie and Zend_Http_CookieJar
Zend_Http_Response
Zend_InfoCard
Introduction
Zend_Json
Introduction
Basic Usage
Advanced Usage of Zend_Json
XML to JSON conversion
Zend_Json_Server - JSON-RPC server
Zend_Layout
Introduction
Zend_Layout Quick Start
Zend_Layout Configuration Options
Zend_Layout Advanced Usage
Zend_Ldap
Introduction
Zend_Loader
Loading Files and Classes Dynamically
The Autoloader
Resource Autoloaders
Loading Plugins
Zend_Locale
Introduction
Using Zend_Locale
Normalization and Localization
Working with Dates and Times
Supported locales
Migrating from previous versions
Zend_Log
Overview
Writers
Formatters
Filters
Zend_Mail
Introduction
Sending via SMTP
Sending Multiple Mails per SMTP Connection
Using Different Transports
HTML E-Mail
Attachments
Adding Recipients
Controlling the MIME Boundary
Additional Headers
Character Sets
Encoding
SMTP Authentication
Securing SMTP Transport
Reading Mail Messages
Zend_Measure
Introduction
Creation of Measurements
Outputting measurements
Manipulating Measurements
Types of measurements
Zend_Memory
Overview
Memory Manager
Memory Objects
Zend_Mime
Zend_Mime
Zend_Mime_Message
Zend_Mime_Part
Zend_Navigation
Introduction
Pages
Containers
Zend_OpenId
Introduction
Zend_OpenId_Consumer Basics
Zend_OpenId_Provider
Zend_Paginator
Introduction
Usage
Configuration
Advanced usage
Zend_Pdf
Introduction
Creating and Loading PDF Documents
Save Changes to PDF Documents
Working with Pages
Drawing
Document Info and Metadata.
Zend_Pdf module usage example
Zend_ProgressBar
Zend_ProgressBar
Zend_Reflection
Introduction
Zend_Reflection Examples
Zend_Reflection Reference
Zend_Registry
Using the Registry
Zend_Rest
Introduction
Zend_Rest_Client
Zend_Rest_Server
Zend_Search_Lucene
Overview
Building Indexes
Searching an Index
Query Language
Query Construction API
Character Set
Extensibility
Interoperating with Java Lucene
Advanced
Best Practices
Zend_Server
Introduction
Zend_Server_Reflection
Zend_Service
Introduction
Zend_Service_Akismet
Zend_Service_Amazon
Zend_Service_Amazon_Ec2
Zend_Service_Amazon_Ec2: Instances
Zend_Service_Amazon_Ec2: Windows Instances
Zend_Service_Amazon_Ec2: Reserved Instances
Zend_Service_Amazon_Ec2: CloudWatch Monitoring
Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)
Zend_Service_Amazon_Ec2: Elastic Block Stroage (EBS)
Zend_Service_Amazon_Ec2: Elastic IP Addresses
Zend_Service_Amazon_Ec2: Keypairs
Zend_Service_Amazon_Ec2: Regions and Availability Zones
Zend_Service_Amazon_Ec2: Security Groups
Zend_Service_Amazon_S3
Zend_Service_Audioscrobbler
Zend_Service_Delicious
Zend_Service_Flickr
Zend_Service_Nirvanix
Zend_Service_ReCaptcha
Zend_Service_Simpy
Introduction
Zend_Service_StrikeIron
Zend_Service_StrikeIron: Bundled Services
Zend_Service_StrikeIron: Advanced Uses
Zend_Service_Technorati
Zend_Service_Twitter
Zend_Service_Yahoo
Zend_Session
Introduction
Basic Usage
Advanced Usage
Global Session Management
Zend_Session_SaveHandler_DbTable
Zend_Soap
Zend_Soap_Server
Zend_Soap_Client
WSDL Accessor
AutoDiscovery
Zend_Tag
Introduction
Zend_Tag_Cloud
Zend_Test
Introduction
Zend_Test_PHPUnit
Zend_Text
Zend_Text_Figlet
Zend_Text_Table
Zend_TimeSync
Introduction
Working with Zend_TimeSync
Zend_Tool_Framework
Introduction
Using the CLI Tool
Architecture
Creating Providers to use with Zend_Tool_Framework
Shipped System Providers
Zend_Tool_Project
Zend_Tool_Project Introduction
Create A Project
Zend Tool Project Providers
Zend_Translate
Introduction
Adapters for Zend_Translate
Using Translation Adapters
Migrating from previous versions
Zend_Uri
Zend_Uri
Zend_Validate
Introduction
Standard Validation Classes
Validator Chains
Writing Validators
Validation Messages
Zend_Version
Getting the Zend Framework Version
Zend_View
Introduction
Controller Scripts
View Scripts
View Helpers
Zend_View_Abstract
Migrating from Previous Versions
Zend_Wildfire
Zend_Wildfire
Zend_XmlRpc
Introduction
Zend_XmlRpc_Client
Zend_XmlRpc_Server
Zend Framework Requirements
Introduction
Zend Framework Coding Standard for PHP
Overview
PHP File Formatting
Naming Conventions
Coding Style
Zend Framework Performance Guide
Introduction
Class Loading
Zend_Db Performance
Internationalization (i18n) and Localization (l10n)
View Rendering
Copyright Information