Ticket #377: wshelper.diff

File wshelper.diff, 6.3 kB (added by sylvain261, 9 months ago)

Oubli ! Une Maj de wshelper permettant d'avoir des tableaux associatifs (patch nécessaire pour testapp)

  • lib/wshelper/IPReflectionCommentParser.class.php

    old new  
    129129                        case 'param': 
    130130                                $o = new stdClass(); 
    131131                                $o->type = trim($tagArr[1]); 
     132                                $o->name= str_replace('$', '', trim($tagArr[2])); 
    132133                                $o->comment = implode(" ",$tagArr); 
    133                                 $this->obj->params[] = $o; 
     134                                $this->obj->parameters[$o->name] = $o; 
    134135                                break; 
    135136                        case 'return': 
    136137                                $this->obj->return = trim($tagArr[1]); break; 
  • lib/wshelper/IPReflectionMethod.class.php

    old new  
    6565         * @return ReflectionParameter[] Associative array with parameter objects 
    6666         */ 
    6767        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                  
    7768                return $this->parameters; 
    7869        } 
    7970 
  • lib/wshelper/IPXMLSchema.class.php

    old new  
    2828         
    2929        public function addComplexType($type, $name = false, $parent = false) { 
    3030                if(!$parent){//outline element 
     31 
     32                        if(substr($name,-4) == '[=>]'){ 
     33                                $name = substr($name, 0,strlen($name) -4); 
     34                        } 
     35                         
    3136                        //check if the complexType doesn't already exists 
    3237                        if(isset($this->types[$name])) return $this->types[$name]; 
    3338 
     
    4550                if(strtolower(substr($type,0,6)) == 'array(' || substr($type,-2) == '[]'){ 
    4651                        $this->addArray($type,$complexTypeTag); 
    4752                }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); 
    6257                        }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?"); 
    6560                                $v = new IPReflectionClass($name); 
    6661                                //TODO: check if the class extends another class? 
    6762                                $properties = $v->getProperties(false, false, false);//not protected and private properties 
     
    107102                                        $el->setAttribute("type", "tns:".$name); 
    108103                                        $this->addComplexType($type, $name, false); 
    109104                                } 
    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                                } 
    113117                        } 
    114118                } 
    115119                return $el; 
  • lib/wshelper/WSDLStruct.class.php

    old new  
    6767        const NS_SOAP = "http://schemas.xmlsoap.org/wsdl/soap/"; 
    6868        const NS_ENC  = "http://schemas.xmlsoap.org/soap/encoding/";  
    6969        const NS_XSD  = "http://www.w3.org/2001/XMLSchema"; 
     70        const NS_APACHE  = "http://xml.apache.org/xml-soap"; 
    7071         
    7172        const CREATE_EMPTY_INPUTS = true; 
    7273         
     
    116117                $definitions->setAttribute("xmlns:SOAP-ENC",    self::NS_ENC); 
    117118                $definitions->setAttribute("xmlns:wsdl",                self::NS_WSDL); 
    118119                $definitions->setAttribute("xmlns:xsd",                 self::NS_XSD); 
     120                $definitions->setAttribute("xmlns:apache",              self::NS_APACHE); 
    119121                $definitions->setAttribute("xmlns:tns",                 $this->tns); 
    120122                $definitions->setAttribute("targetNamespace",   $this->tns); 
    121123 
     
    284286                        if($t = IPXMLSchema::checkSchemaType(strtolower($partType))) 
    285287                                $part->setAttribute("type", "xsd:".$t); 
    286288                        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                                } 
    292302                        } 
    293303                } 
    294304        } 
Download in other formats: Original Format