/** * Returns an XSD Type for the given PHP type * * @param string $type PHP Type to get the XSD type for * @return string */ public function getType($type) { if (!$this->_wsdl instanceof Zend_Soap_Wsdl) { /** @todo Exception throwing may be more correct */ // WSDL is not defined yet, so we can't recognize type in context of current service return ''; } else { return $this->_wsdl->getType($type); } }
function testGetType() { $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); $this->assertEquals($wsdl->getType('string'), 'xsd:string'); $this->assertEquals($wsdl->getType('str'), 'xsd:string'); $this->assertEquals($wsdl->getType('int'), 'xsd:int'); $this->assertEquals($wsdl->getType('integer'), 'xsd:int'); $this->assertEquals($wsdl->getType('float'), 'xsd:float'); $this->assertEquals($wsdl->getType('double'), 'xsd:float'); $this->assertEquals($wsdl->getType('boolean'), 'xsd:boolean'); $this->assertEquals($wsdl->getType('bool'), 'xsd:boolean'); $this->assertEquals($wsdl->getType('array'), 'soap-enc:Array'); $this->assertEquals($wsdl->getType('object'), 'xsd:struct'); $this->assertEquals($wsdl->getType('mixed'), 'xsd:anyType'); $this->assertEquals($wsdl->getType('void'), ''); $this->assertEquals($wsdl->getType('Zend_Soap_Wsdl_Test'), 'tns:Zend_Soap_Wsdl_Test'); $wsdl1 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', false); $this->assertEquals($wsdl1->getType('Zend_Soap_Wsdl_Test'), 'xsd:anyType'); }
/** * @group ZF-3910 */ function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() { $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); $this->assertEquals("xsd:string", $wsdl->getType("StrIng")); $this->assertEquals("xsd:string", $wsdl->getType("sTr")); $this->assertEquals("xsd:int", $wsdl->getType("iNt")); $this->assertEquals("xsd:int", $wsdl->getType("INTEGER")); $this->assertEquals("xsd:float", $wsdl->getType("FLOAT")); $this->assertEquals("xsd:float", $wsdl->getType("douBLE")); }
/** * @group ZF-11937 */ public function testWsdlGetTypeWillAllowLongType() { $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); $this->assertEquals("xsd:long", $wsdl->getType("long")); }
/** * Add a W3C defined type. * * This is based upon the built-in datatypes as defined at * {@link http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-datatypes Built-in datatypes}. * Not all the types are supported, specifically: * 1. anySimpleType * 2. ENTITIES * 3. ENTITY * 4. ID * 5. IDREF * 6. IDREFS * 7. language * 8. Name * 9. NCName * 10. negativeInteger * 11. NMTOKEN * 12. NMTOKENS * 13. nonNegativeInteger * 14. nonPositiveInteger * 15. NOTATION * 16. positiveInteger * 17. QName * 18. unsignedByte * 19. unsignedInt * 20. unsignedLong * 21. unsignedShort * * Additionally, new built-in datatypes, as defined at * {@link http://www.w3.org/TR/xmlschema11-2/datatypes.html#built-in-datatypes Built-in Datatypes and Their Definitions} * are not supported. These include: * 1. anyAtomicType * 2. dayTimeDuration * 3. dayTimeStamp - This type can to be supported via the dateTime type with the optional timezone element always being populated. * 4. precisionDecimal * 5. yearMonthDuration * * @param string $type Name of the type to be specified * * @return string XSD Type for the given PHP type * * @uses Zend_Soap_Wsdl::getType() to handle all unknown types. */ public function getType($type) { return isset(self::$XSDTypeMap[strtolower($type)]) ? self::$XSDTypeMap[strtolower($type)] : parent::getType($type); }