Ticket #377: wshelper.diff
| File wshelper.diff, 6.3 kB (added by sylvain261, 9 months ago) |
|---|
-
lib/wshelper/IPReflectionCommentParser.class.php
old new 129 129 case 'param': 130 130 $o = new stdClass(); 131 131 $o->type = trim($tagArr[1]); 132 $o->name= str_replace('$', '', trim($tagArr[2])); 132 133 $o->comment = implode(" ",$tagArr); 133 $this->obj->param s[] = $o;134 $this->obj->parameters[$o->name] = $o; 134 135 break; 135 136 case 'return': 136 137 $this->obj->return = trim($tagArr[1]); break; -
lib/wshelper/IPReflectionMethod.class.php
old new 65 65 * @return ReflectionParameter[] Associative array with parameter objects 66 66 */ 67 67 public function getParameters(){ 68 $this->parameters = Array();69 $ar = parent::getParameters();70 $i = 0;71 72 foreach((array)$ar as $parameter){73 $parameter->type = $this->params[$i++]->type;74 $this->parameters[$parameter->name] = $parameter;75 }76 77 68 return $this->parameters; 78 69 } 79 70 -
lib/wshelper/IPXMLSchema.class.php
old new 28 28 29 29 public function addComplexType($type, $name = false, $parent = false) { 30 30 if(!$parent){//outline element 31 32 if(substr($name,-4) == '[=>]'){ 33 $name = substr($name, 0,strlen($name) -4); 34 } 35 31 36 //check if the complexType doesn't already exists 32 37 if(isset($this->types[$name])) return $this->types[$name]; 33 38 … … 45 50 if(strtolower(substr($type,0,6)) == 'array(' || substr($type,-2) == '[]'){ 46 51 $this->addArray($type,$complexTypeTag); 47 52 }else{//it should be an object 48 $tag=$this->addElement("xsd:all", $complexTypeTag); 49 //check if it has the name 'object()' (kind of a stdClass) 50 if(strtolower(substr($type,0,6)) == 'object'){//stdClass 51 $content = substr($type, 7, (strlen($type)-1)); 52 $properties = split(",", $content);//split the content into properties 53 foreach((array)$properties as $property){ 54 if($pos = strpos($property, "=>")){//array with keys (order is important, so use 'sequence' tag) 55 $keyType = substr($property,6,($pos-6)); 56 $valueType = substr($property,($pos+2), (strlen($property)-7)); 57 $el->$this->addTypeElement($valueType, $keyType, $tag); 58 }else{ 59 throw new WSDLException("Error creating WSDL: expected \"=>\". When using the object() as type, use it as object(paramname=>paramtype,paramname2=>paramtype2)"); 60 } 61 } 53 if(substr($type,-4) == '[=>]'){ 54 $type = substr($type, 0,strlen($type) -4); 55 echo("\nAdd type element :$type \n"); 56 $this->addTypeElement($type, $name, $complexTypeTag); 62 57 }else{ //should be a known class 63 64 if(!class_exists($name ), false) throw new WSDLException("Error creating WSDL: no class found with the name '$name' / $type : $parent, so how should we know the structure for this datatype?");58 $tag=$this->addElement("xsd:all", $complexTypeTag); 59 if(!class_exists($name, FALSE)) throw new WSDLException("Error creating WSDL: no class found with the name '$name' / $type : $parent, so how should we know the structure for this datatype?"); 65 60 $v = new IPReflectionClass($name); 66 61 //TODO: check if the class extends another class? 67 62 $properties = $v->getProperties(false, false, false);//not protected and private properties … … 107 102 $el->setAttribute("type", "tns:".$name); 108 103 $this->addComplexType($type, $name, false); 109 104 } 110 }else{//else, new complextype, outline (element with 'ref' attrib) 111 $el->setAttribute("type", "tns:".$type); 112 $this->addComplexType($type, $type); 105 }else{ 106 if(substr($type,-4) == '[=>]'){ 107 $name = substr($type, 0, -4); 108 $el->setAttribute("type", "apache:Map"); 109 if(!$this->checkSchemaType(strtolower($name))){ 110 $this->addComplexType($name, $name, false); 111 } 112 }else{ 113 //else, new complextype, outline (element with 'ref' attrib) 114 $el->setAttribute("type", "tns:".$type); 115 $this->addComplexType($type, $type); 116 } 113 117 } 114 118 } 115 119 return $el; -
lib/wshelper/WSDLStruct.class.php
old new 67 67 const NS_SOAP = "http://schemas.xmlsoap.org/wsdl/soap/"; 68 68 const NS_ENC = "http://schemas.xmlsoap.org/soap/encoding/"; 69 69 const NS_XSD = "http://www.w3.org/2001/XMLSchema"; 70 const NS_APACHE = "http://xml.apache.org/xml-soap"; 70 71 71 72 const CREATE_EMPTY_INPUTS = true; 72 73 … … 116 117 $definitions->setAttribute("xmlns:SOAP-ENC", self::NS_ENC); 117 118 $definitions->setAttribute("xmlns:wsdl", self::NS_WSDL); 118 119 $definitions->setAttribute("xmlns:xsd", self::NS_XSD); 120 $definitions->setAttribute("xmlns:apache", self::NS_APACHE); 119 121 $definitions->setAttribute("xmlns:tns", $this->tns); 120 122 $definitions->setAttribute("targetNamespace", $this->tns); 121 123 … … 284 286 if($t = IPXMLSchema::checkSchemaType(strtolower($partType))) 285 287 $part->setAttribute("type", "xsd:".$t); 286 288 else{ 287 //If it is an array, change the type name 288 $partName = (substr($partType,-2) == "[]")?substr($partType,0,strpos($partType,"["))."Array":$partType; 289 290 $part->setAttribute("type", "tns:".$partName); 291 $this->xmlSchema->addComplexType($partType, $partName); 289 //If it is an associative array, change the type name 290 if(substr($partType,-4) == "[=>]"){ 291 $partType = substr($partType,0, strlen($partType)-4); 292 if(!IPXMLSchema::checkSchemaType(strtolower($partType))){ 293 $partName = $partType; 294 $this->xmlSchema->addComplexType($partType, $partName); 295 } 296 $part->setAttribute("type", "apache:Map"); 297 }else{ 298 $partName = (substr($partType,-2) == "[]")?substr($partType,0,strpos($partType,"["))."Array":$partType; 299 $part->setAttribute("type", "tns:".$partName); 300 $this->xmlSchema->addComplexType($partType, $partName); 301 } 292 302 } 293 303 } 294 304 }
