Table of Contents
In addition to primitive data types (such as integers or strings) Recite web services uses a number of custom data types. Each custom type that is used is specified in the WSDL of the web service that uses it. In order to make use of these custom types we must map the type to a local PHP class.
For example, if you call the getPage()
method of the
pages web service, according to the WSDL the type returned is
Module_Pages_Webservies_Page
. In order to easily make use of the
data included in this data type, we create a local PHP to map this class.
Fortunately, the bundled class does this for us automatically. In this particular
example, we have a PHP class called Recite_Pages_Page
(located in
./Recite/Pages/Page.php
). When we use the Recite_Webservices::factory('pages')
call to use the pages
web service it will automatically create the mapping between the PHP class and the custom
type in the WSDL.
Class mapping does not only correspond to data returned from web services; many of the
methods in Recite web services accept complex types as arguments to the function call. For
example, the pages method getPage()
accepts an instance of
Module_Pages_Webservices_Options_GetPages
. The bundled client
automatically maps this to the local class
Recite_Pages_Options_GetPages
.
Here's an example of using the mapped classes:
Example 2.1. Using Mapped Classes
<?php require_once('Recite/Webservices.php'); // ... set the end point and authentication // create the SOAP client $client = Recite_Webservices::Factory('pages'); // build the options for the getPages() call $options = new Recite_Pages_Options_GetPages(); // retrieve the pages, an array of Recite_Pages_Page $pages = $client->getPages($options); ?>
You don't even need to reference the type name as it appears in the WSDL file. You will however need to know which class to use based on the mappings.
WSDL Data Type | Mapped PHP Class Name |
---|---|
Module_Assets_Webservices_Options_GetFiles | Recite_Assets_Options_GetFiles |
Module_Assets_Webservices_File | Recite_Assets_File |
Module_Assets_Webservices_GetFilesResult | Recite_Assets_GetFilesResult |
Module_Webservices_Auth_AuthenticateRequest | Recite_Auth_AuthenticateRequest |
Module_Webservices_Auth_AuthenticateResponse | Recite_Auth_AuthenticateResponse |
Module_Calendar_Webservices_Event_List | Recite_Calendar_Event_List |
Module_Calendar_Webservices_Event_Type | Recite_Calendar_Event_Type |
Module_Calendar_Webservices_Options_GetCalendars | Recite_Calendar_Options_GetCalendars |
Module_Calendar_Webservices_Options_GetEvents | Recite_Calendar_Options_GetEvents |
Module_Calendar_Webservices_Calendar | Recite_Calendar_Calendar |
Module_Calendar_Webservices_Category | Recite_Calendar_Category |
Module_Calendar_Webservices_DateRange | Recite_Calendar_DateRange |
Module_Calendar_Webservices_Event | Recite_Calendar_Event |
Module_Ecommerce_Webservices_Options_GetCategories | Recite_Ecommerce_Options_GetCategories |
Module_Ecommerce_Webservices_Options_GetProducts | Recite_Ecommerce_Options_GetProducts |
Module_Ecommerce_Webservices_Product_Type | Recite_Ecommerce_Product_Type |
Module_Ecommerce_Webservices_Category | Recite_Ecommerce_Category |
Module_Ecommerce_Webservices_GetProductsResult | Recite_Ecommerce_GetProductsResult |
Module_Ecommerce_Webservices_Product | Recite_Ecommerce_Product |
Module_Forms_Webservices_Element_Container | Recite_Forms_Element_Container |
Module_Forms_Webservices_FieldList | Recite_Forms_FieldList |
Module_Forms_Webservices_FieldList_Field | Recite_Forms_FieldList_Field |
Module_Forms_Webservices_Processor_Options | Recite_Forms_Processor_Options |
Module_Forms_Webservices_Element | Recite_Forms_Element |
Module_Forms_Webservices_Error | Recite_Forms_Error |
Module_Forms_Webservices_Form | Recite_Forms_Form |
Module_Forms_Webservices_Response | Recite_Forms_Response |
Module_Listings_Webservices_Listing_Type | Recite_Listings_Listing_Type |
Module_Listings_Webservices_Options_GetCategories | Recite_Listings_Options_GetCategories |
Module_Listings_Webservices_Options_GetListings | Recite_Listings_Options_GetListings |
Module_Listings_Webservices_Category | Recite_Listings_Category |
Module_Listings_Webservices_GetListingsResult | Recite_Listings_GetListingsResult |
Module_Listings_Webservices_Listing | Recite_Listings_Listing |
Module_Pages_Webservices_Options_GetPages | Recite_Pages_Options_GetPages |
Module_Pages_Webservices_Page | Recite_Pages_Page |
Module_Search_Webservices_Options_Search | Recite_Search_Options_Search |
Module_Search_Webservices_SearchResult | Recite_Search_SearchResult |
Module_Search_Webservices_SearchResult_Item | Recite_Search_SearchResult_Item |
Module_Search_Webservices_SearchIndex | Recite_Search_SearchIndex |
Module_Templates_Webservices_Options_GetTemplates | Recite_Templates_Options_GetTemplates |
Module_Templates_Webservices_Template | Recite_Templates_Template |
Module_Users_Webservices_Options_GetUsers | Recite_Users_Options_GetUsers |
Module_Users_Webservices_User_Directory | Recite_Users_User_Directory |
Module_Users_Webservices_GetUsersResult | Recite_Users_GetUsersResult |
Module_Users_Webservices_User | Recite_Users_User |
Module_Webservices_Types_ContentBlock | Recite_Webservices_Types_ContentBlock |
Module_Webservices_Types_Pager | Recite_Webservices_Types_Pager |