Ejemplo n.º 1
0
 /** 
  * Get WSDL for specified model. 
  * 
  * @param string $modelClass : model name in camel case 
  * @param string $serviceMethod : method of the controller that will handle SOAP calls 
  */
 function getWSDL($modelId, $serviceMethod = 'call')
 {
     $modelClass = $this->__getModelClass($modelId);
     $expireTime = '+1 year';
     $cachePath = $modelClass . '.wsdl';
     // Check cache if exist
     $wsdl = cache($cachePath, null, $expireTime);
     // If DEBUG > 0, compare cache modified time to model file modified time
     if (Configure::read() > 0 && !is_null($wsdl)) {
         $cacheFile = CACHE . $cachePath;
         if (is_file($cacheFile)) {
             $modelMtime = filemtime($this->__getModelFile($modelId));
             $cacheMtime = filemtime(CACHE . $cachePath);
             if ($modelMtime > $cacheMtime) {
                 $wsdl = null;
             }
         }
     }
     // Generate WSDL if not cached
     if (is_null($wsdl)) {
         $refl = new IPReflectionClass($modelClass);
         $controllerName = $this->params['controller'];
         $serviceURL = Router::url("/{$controllerName}/{$serviceMethod}", true);
         $wsdlStruct = new WSDLStruct('http://schema.example.com', $serviceURL . '/' . $modelId, SOAP_RPC, SOAP_LITERAL);
         $wsdlStruct->setService($refl);
         try {
             $wsdl = $wsdlStruct->generateDocument();
             // cache($cachePath, $wsdl, $expireTime);
         } catch (WSDLException $exception) {
             if (Configure::read() > 0) {
                 $exception->Display();
                 exit;
             } else {
                 return null;
             }
         }
     }
     return $wsdl;
 }
Ejemplo n.º 2
0
 /**
  * Generate the WSDL content
  */
 private function _compile()
 {
     $url = jUrl::get($this->module . '~' . $this->controller . ':index@soap', array(), jUrl::JURL);
     $url->clearParam();
     $url->setParam('service', $this->module . '~' . $this->controller);
     $serverUri = jUrl::getRootUrlRessourceValue('soap');
     if ($serverUri === null) {
         $serverUri = jUrl::getRootUrlRessourceValue('soap-' . $this->module);
     }
     if ($serverUri === null) {
         $serverUri = jUrl::getRootUrlRessourceValue('soap-' . $this->module . '-' . $this->controller);
     }
     if ($serverUri === null) {
         $serverUri = jApp::coord()->request->getServerURI();
     }
     $serviceURL = $serverUri . $url->toString();
     $serviceNameSpace = $serverUri . jApp::urlBasePath();
     $wsdl = new WSDLStruct($serviceNameSpace, $serviceURL, SOAP_RPC, SOAP_ENCODED);
     $wsdl->setService(new IPReflectionClass($this->controllerClassName));
     try {
         $gendoc = $wsdl->generateDocument();
     } catch (WSDLException $exception) {
         throw new JException('jsoap~errors.wsdl.generation', $exception->msg);
     }
     return $gendoc;
 }
Ejemplo n.º 3
0
 public function testAssociativeArray()
 {
     $class = new IPReflectionClass('testWsdlWithAssocArray');
     $wsdl = new WSDLStruct('http://localhost/my/namespace', 'http://localhost/wsdl/uri');
     $wsdl->setService($class);
     $gendoc = $wsdl->generateDocument();
     $gendoc = str_replace('><', ">\n<", $gendoc);
     $expected = '<' . '?xml version="1.0"?' . '>' . "\n";
     $expected .= '<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:apache="http://xml.apache.org/xml-soap" xmlns:tns="http://localhost/my/namespace" targetNamespace="http://localhost/my/namespace">' . "\n";
     $expected .= '<wsdl:types>' . "\n";
     $expected .= '<xsd:schema targetNamespace="http://localhost/my/namespace">' . "\n";
     $expected .= '<xsd:import namespace="http://xml.apache.org/xml-soap"/>' . "\n";
     $expected .= '<xsd:complexType name="testWsdlSimpleClass">' . "\n";
     $expected .= '<xsd:all/>' . "\n";
     $expected .= '</xsd:complexType>' . "\n";
     $expected .= '<xsd:complexType name="ArrayOfAssociativeArrayOftestWsdlSimpleClass">' . "\n";
     $expected .= '<xsd:complexContent>' . "\n";
     $expected .= '<xsd:restriction base="SOAP-ENC:Array">' . "\n";
     $expected .= '<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="apache:Map[]"/>' . "\n";
     $expected .= '</xsd:restriction>' . "\n";
     $expected .= '</xsd:complexContent>' . "\n";
     $expected .= '</xsd:complexType>' . "\n";
     $expected .= '</xsd:schema>' . "\n";
     $expected .= '</wsdl:types>' . "\n";
     $expected .= '<message name="meth1Request">' . "\n";
     $expected .= '<part name="arr1" type="apache:Map"/>' . "\n";
     $expected .= '</message>' . "\n";
     $expected .= '<message name="meth2Request">' . "\n";
     $expected .= '<part name="arr2" type="apache:Map"/>' . "\n";
     $expected .= '</message>' . "\n";
     $expected .= '<message name="meth2Response">' . "\n";
     $expected .= '<part name="meth2Return" type="apache:Map"/>' . "\n";
     $expected .= '</message>' . "\n";
     $expected .= '<message name="meth3Request">' . "\n";
     $expected .= '<part name="arr3" type="tns:ArrayOfAssociativeArrayOftestWsdlSimpleClass"/>' . "\n";
     $expected .= '</message>' . "\n";
     $expected .= '<wsdl:portType name="testWsdlWithAssocArrayPortType">' . "\n";
     $expected .= '<wsdl:operation name="meth1">' . "\n";
     $expected .= '<wsdl:input message="tns:meth1Request"/>' . "\n";
     $expected .= '</wsdl:operation>' . "\n";
     $expected .= '<wsdl:operation name="meth2">' . "\n";
     $expected .= '<wsdl:input message="tns:meth2Request"/>' . "\n";
     $expected .= '<wsdl:output message="tns:meth2Response"/>' . "\n";
     $expected .= '</wsdl:operation>' . "\n";
     $expected .= '<wsdl:operation name="meth3">' . "\n";
     $expected .= '<wsdl:input message="tns:meth3Request"/>' . "\n";
     $expected .= '</wsdl:operation>' . "\n";
     $expected .= '</wsdl:portType>' . "\n";
     $expected .= '<binding name="testWsdlWithAssocArrayBinding" type="tns:testWsdlWithAssocArrayPortType">' . "\n";
     $expected .= '<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>' . "\n";
     $expected .= '<wsdl:operation name="meth1">' . "\n";
     $expected .= '<soap:operation soapAction="http://localhost/wsdl/uri&amp;method=meth1" style="rpc"/>' . "\n";
     $expected .= '<wsdl:input>' . "\n";
     $expected .= '<soap:body use="encoded" namespace="http://localhost/my/namespace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' . "\n";
     $expected .= '</wsdl:input>' . "\n";
     $expected .= '</wsdl:operation>' . "\n";
     $expected .= '<wsdl:operation name="meth2">' . "\n";
     $expected .= '<soap:operation soapAction="http://localhost/wsdl/uri&amp;method=meth2" style="rpc"/>' . "\n";
     $expected .= '<wsdl:input>' . "\n";
     $expected .= '<soap:body use="encoded" namespace="http://localhost/my/namespace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' . "\n";
     $expected .= '</wsdl:input>' . "\n";
     $expected .= '<wsdl:output>' . "\n";
     $expected .= '<soap:body use="encoded" namespace="http://localhost/my/namespace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' . "\n";
     $expected .= '</wsdl:output>' . "\n";
     $expected .= '</wsdl:operation>' . "\n";
     $expected .= '<wsdl:operation name="meth3">' . "\n";
     $expected .= '<soap:operation soapAction="http://localhost/wsdl/uri&amp;method=meth3" style="rpc"/>' . "\n";
     $expected .= '<wsdl:input>' . "\n";
     $expected .= '<soap:body use="encoded" namespace="http://localhost/my/namespace" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>' . "\n";
     $expected .= '</wsdl:input>' . "\n";
     $expected .= '</wsdl:operation>' . "\n";
     $expected .= '</binding>' . "\n";
     $expected .= '<wsdl:service name="testWsdlWithAssocArray">' . "\n";
     $expected .= '<wsdl:port name="testWsdlWithAssocArrayPort" binding="tns:testWsdlWithAssocArrayBinding">' . "\n";
     $expected .= '<soap:address location="http://localhost/wsdl/uri"/>' . "\n";
     $expected .= '</wsdl:port>' . "\n";
     $expected .= '</wsdl:service>' . "\n";
     $expected .= '</wsdl:definitions>' . "\n";
     $this->assertEquals($expected, $gendoc);
 }
Ejemplo n.º 4
0
 /**
  * Get WSDL for specified model.
  *
  * @param string $modelClass    : model name in camel case
  * @param string $serviceMethod : method of the controller that will handle SOAP calls
  */
 public function getWSDL($controllId, $serviceMethod = 'call')
 {
     $inflector = new Inflector();
     $controllClass = $inflector->camelize($controllId);
     $expireTime = '+1 year';
     $cachePath = $controllClass . '.wsdl';
     // Check cache if exist
     $wsdl = cache($cachePath, null, $expireTime);
     // If DEBUG > 0, compare cache modified time to model file modified time
     if (Configure::read() > 0 && !is_null($wsdl)) {
         $cacheFile = CACHE . $cachePath;
         if (is_file($cacheFile)) {
             $modelMtime = filemtime($this->__getControllFile($controllId));
             $cacheMtime = filemtime(CACHE . $cachePath);
             if ($modelMtime > $cacheMtime) {
                 $wsdl = null;
             }
         }
     }
     // Generate WSDL if not cached
     if (is_null($wsdl)) {
         $refl = new IPReflectionClass($controllClass . 'Controller');
         $serviceURL = Router::url('/' . $this->__settings['prefix'] . '/' . low($controllClass) . "/{$serviceMethod}", true);
         $wsdlStruct = new WSDLStruct('http://partner.seevia.cn', $serviceURL, SOAP_RPC, SOAP_LITERAL);
         $wsdlStruct->setService($refl);
         //	print_r($wsdlStruct);
         try {
             $wsdl = $wsdlStruct->generateDocument();
             // cache($cachePath, $wsdl, $expireTime);
         } catch (WSDLException $exception) {
             if (Configure::read() > 0) {
                 $exception->Display();
                 exit;
             } else {
                 return;
             }
         }
     }
     return $wsdl;
 }
Ejemplo n.º 5
0
 private function createWSDL()
 {
     $this->class = new IPReflectionClass($this->name);
     $wsdl = new WSDLStruct($this->uri, 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?class=' . $this->name, $this->type, $this->use);
     $wsdl->setService($this->class);
     $gendoc = $wsdl->generateDocument();
     $fh = fopen($this->wsdlfile, 'w+');
     fwrite($fh, $gendoc);
     fclose($fh);
     return $gendoc;
 }
Ejemplo n.º 6
0
 private function createWSDL()
 {
     $this->class = new IPReflectionClass($this->name);
     $wsdl = new WSDLStruct($this->uri, "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?class=" . $this->name, $this->type, $this->use);
     $wsdl->setService($this->class);
     try {
         $gendoc = $wsdl->generateDocument();
     } catch (WSDLException $exception) {
         $exception->Display();
         exit;
     }
     $fh = fopen($this->wsdlfile, "w+");
     fwrite($fh, $gendoc);
     fclose($fh);
     return $gendoc;
 }
Ejemplo n.º 7
0
 /**
  * Generate the WSDL content
  */
 private function _compile()
 {
     global $gJConfig;
     $url = jUrl::get($this->module . '~' . $this->controller . ':index@soap', array(), jUrl::JURL);
     $url->clearParam();
     $url->setParam('service', $this->module . '~' . $this->controller);
     $serviceURL = "http://" . $_SERVER['HTTP_HOST'] . $url->toString();
     $serviceNameSpace = "http://" . $_SERVER['HTTP_HOST'] . $gJConfig->urlengine['basePath'];
     $wsdl = new WSDLStruct($serviceNameSpace, $serviceURL, SOAP_RPC, SOAP_ENCODED);
     $wsdl->setService(new IPReflectionClass($this->controllerClassName));
     try {
         $gendoc = $wsdl->generateDocument();
     } catch (WSDLException $exception) {
         throw new JException('jWSDL~errors.wsdl.generation', $exception->msg);
     }
     return $gendoc;
 }
Ejemplo n.º 8
0
 private function _compile()
 {
     $url = jUrl::get($this->module . '~' . $this->controller . ':index@soap', array(), jUrl::JURL);
     $url->clearParam();
     $url->setParam('service', $this->module . '~' . $this->controller);
     $serviceURL = $serviceNameSpace = jApp::coord()->request->getServerURI();
     $serviceURL .= $url->toString();
     $serviceNameSpace .= jApp::config()->urlengine['basePath'];
     $wsdl = new WSDLStruct($serviceNameSpace, $serviceURL, SOAP_RPC, SOAP_ENCODED);
     $wsdl->setService(new IPReflectionClass($this->controllerClassName));
     try {
         $gendoc = $wsdl->generateDocument();
     } catch (WSDLException $exception) {
         throw new JException('jWSDL~errors.wsdl.generation', $exception->msg);
     }
     return $gendoc;
 }