<? PHP/** * Copyright (c)2005, Braulio Jos? Solano Rojas*All rights reserved.* * Redistribution andUseinchSource andBinary forms, with orwithout modification, is*permitted provided that the following conditions is met:* * redistributions ofSource code must retain the above copyright notice, this list of* Conditions andThe following disclaimer. * RedistributionsinchBinary form must reproduce the above copyright notice, this list of* Conditions andThe following disclaimerinchThe documentation and/orOther materials* Provided withThe distribution. * Neither the name ofThe Solsoft de Costa Rica S.A. nor the names ofIts contributors may* be used toEndorseorpromote products derived from this software without specific*prior written permission.* * This Software isProvided by the COPYRIGHT holders and* CONTRIBUTORS" as is" andAny EXPRESSORimplied warranties,* Including, but notLIMITED to, the implied warranties of* merchantability andFITNESS forA particular PURPOSE is* disclaimed.inchNOEVENTShall the COPYRIGHT OWNEROR* CONTRIBUTORS be liable forAny DIRECT, INDIRECT, incidental,* Special, exemplary,ORconsequential damages (including, but* notLIMITED to, procurement ofSubstitute GOODSORSERVICES;* LOSS ofUse, DATA,ORProfits;ORBusiness Interruption)* However caused and onAny theory ofLiability, WHETHERinch* Contract,STRICTLiability,ORTORT (including negligenceOR* OTHERWISE) arisinginchAny-out ofThe use ofThis software,* EvenIFAdvised ofThe possibility ofSUCH DAMAGE.* * * @version $Id: SoapDiscovery.class.php the --Geneva-Ten -: A: 21Z IDEAA $* @copyright2005*//** * SoapdiscoveryClassThat provides Web Service Definition Language (WSDL).* *@package soapdiscovery*@author Braulio Jos? Solano Rojas* @copyright Copyright (c)2005Braulio Jos? Solano Rojas* @version $Id: SoapDiscovery.class.php the --Geneva-Ten -: A: 21Z IDEAA $* @access Public* */classSoapdiscovery {Private$class _name =''; Private$service _name ='';/** * SOAPDISCOVERY::__CONSTRUCT () soapdiscoveryclassConstructor. * * @paramstring$class _name* @paramstring$service _name* */ Public function__construct ($class _name ='', $service _name = ') {$this->class_name =$class _name; $this->service_name =$service _name; } /** * SOAPDISCOVERY::GETWSDL () Returns the WSDL ofAclass ifTheclass isinstantiable. * * @return string* */ Public functiongetwsdl () {if(Empty ($thisservice_name)) { Throw NewException ('No service name. ');} $headerWSDL="<?xml version=\"1.0\"? >\n"; $headerWSDL.="<definitions name=\"$this->service_name\"targetnamespace=\"urn: $this->service_name\"xmlns:wsdl=\"Http://schemas.xmlsoap.org/wsdl/\"xmlns:soap=\"Http://schemas.xmlsoap.org/wsdl/soap/\"xmlns:tns=\"urn: $this->service_name\"xmlns:xsd=\"http://www.w3.org/2001/xmlschema\"xmlns:soap-enc=\"Http://schemas.xmlsoap.org/soap/encoding/\"xmlns=\"Http://schemas.xmlsoap.org/wsdl/\">\n"; $headerWSDL.="<types xmlns=\"Http://schemas.xmlsoap.org/wsdl/\"/>\n"; if(Empty ($thisclass_name)) { Throw NewException ('No class name. '); } $class=NewReflectionclass ($thisclass_name); if(!$class-isinstantiable ()) { Throw NewException ('Class is not instantiable. ');} $methods= $class-GetMethods (); $portTypeWSDL='<porttype name= "'. $this->service_name. ' Port ' > ';$bindingWSDL ='<binding name= "'. $this->service_name. ' Binding ' type= "TNS: '. $this->service_name. "Port\" >\n<soap:binding style=\ "rpc\" transport=\ "http://schemas.xmlsoap.org/soap/http\" "/>\n";$serviceWSDL ='<service name= "'. $this->service_name. "\" >\n<documentation/>\n<port name=\ "". $this->service_name. ' Port ' binding= "TNS: '. $this->service_name. "Binding\" ><soap:address location=\ "http:/". $_server[' server_name '. ‘:‘ . $_server[' Server_port '. $_server[' php_self '. "\"/>\n</port>\n</service>\n ";$messageWSDL ='';foreach ($methods as$method) { if($method->ispublic () &&! $methodIsconstructor ()) {$portTypeWSDL.='<operation name= "'. $method->getname (). "\" >\n ". ' <input message=, ' TNS: '. $method->getname (). "Request\"/>\n<output message=\ "TNS:". $method->getname (). "Response\"/>\n</operation>\n ";$bindingWSDL. ='<operation name= "'. $method->getname (). "\" >\n ". ' <soap:operation soapaction= ' urn: '. $this->service_name. ‘#‘ . $this->class_name. ‘#‘ . $method->getname (). "\"/>\n<input><soap:body use=\ "encoded\" namespace=\ "urn: $this->service_name\" EncodingStyle=\ " Http://schemas.xmlsoap.org/soap/encoding/\ "/>\n</input>\n<output>\n<soap:body use=\" encoded\ " Namespace=\ "urn: $this->service_name\" encodingstyle=\ "http://schemas.xmlsoap.org/soap/encoding/\"/>\n< /output>\n</operation>\n ";$messageWSDL. ='<message name= "'. $method->getname (). "Request\" >\n ";$parameters = $methodgetparameters (); foreach ($parameters as$parameter) {$messageWSDL.='<part name= "'. $parameter->getname (). "\" type=\ "xsd:string\"/>\n ";} $messageWSDL.="</message>\n"; $messageWSDL.='<message name= "'. $method->getname (). "Response\" >\n ";$messageWSDL. ='<part name= "'. $method->getname (). "\" type=\ "xsd:string\"/>\n ";$messageWSDL. ="</message>\n"; }} $portTypeWSDL.="</porttype>\n"; $bindingWSDL.="</binding>\n"; //returnsprintf'%s%s%s%s%s%s ', $headerWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, $messageWSDL, ' </definitions> ');//generate the WSDL file with the return comment above $fso= fopen ($this->class_name.". wsdl","W"); Fwrite ($fso, sprintf ('%s%s%s%s%s%s ', $headerWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, $messageWSDL, ' </definitions> '); } /** * soapdiscovery::getdiscovery () Returns discovery ofWSDL. * * @return string* */ Public functionGetdiscovery () {return "<?xml version=\"1.0\"? >\n<disco:discovery xmlns:disco=\"Http://schemas.xmlsoap.org/disco/\"xmlns:scl=\"Http://schemas.xmlsoap.org/disco/scl/\">\n<scl:contractref ref=\"/HTTP". $_server[' server_name ']. ‘:‘ . $_server[' Server_port '. $_server[' php_self '. "? wsdl\"/>\n</disco:discovery>"; }}?>