Advertisement
Guest User

Extension of Zend_Soap_Wsdl to allow w3c data types

a guest
Dec 8th, 2010
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.83 KB | None | 0 0
  1. <?php
  2. /**
  3.  * CamelotWebService
  4.  *
  5.  * @package CamelotWebServices
  6.  * @version $Id: W3C.php,v 1.0.30 2010-11-02T11:56:50+00:00 RichardQ $
  7.  */
  8. class Camelot_Soap_W3C extends Zend_Soap_Wsdl
  9.     {
  10.     /**
  11.      * W3C XSD Type map.
  12.      *
  13.      * This maps the lowercased type to correct cased type.
  14.      *
  15.      * @var array
  16.      */
  17.     static protected $XSDTypeMap = array
  18.         (
  19.         'xsd:anyuri'           => 'xsd:anyURI',
  20.         'xsd:base64binary'     => 'xsd:base64Binary',
  21.         'xsd:boolean'          => 'xsd:boolean',
  22.         'xsd:byte'             => 'xsd:byte',
  23.         'xsd:date'             => 'xsd:date',
  24.         'xsd:datetime'         => 'xsd:dateTime',
  25.         'xsd:decimal'          => 'xsd:decimal',
  26.         'xsd:double'           => 'xsd:double',
  27.         'xsd:duration'         => 'xsd:duration',
  28.         'xsd:float'            => 'xsd:float',
  29.         'xsd:gday'             => 'xsd:gDay',
  30.         'xsd:gmonth'           => 'xsd:gMonth',
  31.         'xsd:gmonthday'        => 'xsd:gMonthDay',
  32.         'xsd:gyear'            => 'xsd:gYear',
  33.         'xsd:gyearmonth'       => 'xsd:gYearMonth',
  34.         'xsd:hexbinary'        => 'xsd:hexBinary',
  35.         'xsd:int'              => 'xsd:int',
  36.         'xsd:integer'          => 'xsd:integer',
  37.         'xsd:long'             => 'xsd:long',
  38.         'xsd:normalizedstring' => 'xsd:normalizedString',
  39.         'xsd:short'            => 'xsd:short',
  40.         'xsd:string'           => 'xsd:string',
  41.         'xsd:time'             => 'xsd:time',
  42.         'xsd:token'            => 'xsd:token',
  43.         );
  44.  
  45.     /**
  46.      * Add a W3C defined type.
  47.      *
  48.      * This is based upon the built-in datatypes as defined at
  49.      * {@link http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-datatypes Built-in datatypes}.
  50.      * Not all the types are supported, specifically :
  51.      * 1. anySimpleType
  52.      * 2. ENTITIES
  53.      * 3. ENTITY
  54.      * 4. ID
  55.      * 5. IDREF
  56.      * 6. IDREFS
  57.      * 7. language
  58.      * 8. Name
  59.      * 9. NCName
  60.      * 10. negativeInteger
  61.      * 11. NMTOKEN
  62.      * 12. NMTOKENS
  63.      * 13. nonNegativeInteger
  64.      * 14. nonPositiveInteger
  65.      * 15. NOTATION
  66.      * 16. positiveInteger
  67.      * 17. QName
  68.      * 18. unsignedByte
  69.      * 19. unsignedInt
  70.      * 20. unsignedLong
  71.      * 21. unsignedShort
  72.      *
  73.      * Additionally, new built-in datatypes, as defined at
  74.      * {@link http://www.w3.org/TR/xmlschema11-2/datatypes.html#built-in-datatypes Built-in Datatypes and Their Definitions}
  75.      * are not supported. These include :
  76.      * 1. anyAtomicType
  77.      * 2. dayTimeDuration
  78.      * 3. dayTimeStamp - This type is going to be supported via the dateTime type with the optional timezone element always being populated.
  79.      * 4. precisionDecimal
  80.      * 5. yearMonthDuration
  81.      *
  82.      * @param  string $type Name of the type to be specified
  83.      *
  84.      * @return string XSD Type for the given PHP type
  85.      *
  86.      * @uses Zend_Soap_Wsdl::getType() to handle all unknown types.
  87.      */
  88.     public function getType($type)
  89.         {
  90.         return isset(self::$XSDTypeMap[strtolower($type)]) ? self::$XSDTypeMap[strtolower($type)] : parent::getType($type);
  91.         }
  92.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement