/**
  Executes the needed operator(s).
  Checks operator names, and calls the appropriate functions.
 */
 function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     switch ($operatorName) {
         case 'washxml':
             $operatorValue = str_replace(array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $operatorValue);
             break;
         case 'washxmlcomment':
             // in xml comments the -- string is not permitted
             $operatorValue = str_replace('--', '_-', $operatorValue);
             break;
         case 'washxmlcdata':
             /// @todo
             eZDebug::writeWarning('Template operator washxmlcdata not yet implemented, it should not be used!', __METHOD__);
             break;
         case 'xsdtype':
             $operatorValue = ggWSDLParser::phpType2xsdType($operatorValue, $namedParameters['targetprefix'], $namedParameters['xsdprefix'], $namedParameters['soapencprefix']);
             break;
         case 'classInspect':
             $operatorValue = ggeZWebservices::classInspect($operatorValue);
             break;
     }
 }
Exemplo n.º 2
0
 /**
  * This method intercepts calls to system.listMethods and syste.methodSignature
  * to transform them into wsdl-based calls. This way client-side code which
  * uses those method calls can be used identically regardless of protocol
  * in use
  */
 function send($request)
 {
     $this->RequestPayload = '';
     $this->ResponsePayload = '';
     /// @todo add a check that request is a soap / phpsoap one, or it will have no namespace method...
     // nb: php soap code wants an integer as SoapVersion, eg. "2" will not work
     $options = array('exceptions' => true, 'soap_version' => (int) $this->SoapVersion);
     if ($this->CacheWSDL >= 0) {
         $options['cache_wsdl'] = $this->CacheWSDL;
     }
     /*
             if ( $this->Login != '' )
             {
                 $options['login'] = $this->Login;
                 $options['password'] = $this->Password;
             }
             if ( $this->Proxy != '' )
             {
                 $options['proxy_host'] = $this->Proxy;
                 $options['proxy_port'] = $this->ProxyPort;
                 if ( $this->ProxyLogin != '' )
                 {
                     $options['proxy_login'] = $this->ProxyLogin;
                     $options['proxy_password'] = $this->ProxyPassword;
                 }
             }*/
     if ($this->Wsdl == null) {
         // non-wsdl mode
         $options['location'] = $this->Protocol . "://" . $this->Server . ":" . $this->Port . $this->Path;
         /// @todo test if request is not a ggsoaprequest / ggphpsoaprequest
         ///       and has thus no ->ns() method
         $options['uri'] = $request->ns();
     } else {
         if (preg_match('#^https?://#', $this->Wsdl) && $this->Timeout != 0) {
             // patch around buggy soapclient behaviour: force socket timeout on getting wsdl call
             $deftimeout = ini_get('default_socket_timeout');
             if ($deftimeout != $this->Timeout) {
                 ini_set('default_socket_timeout', $this->Timeout);
             } else {
                 unset($deftimeout);
             }
         }
     }
     try {
         $response = new $this->ResponseClass();
         $client = new ggPhpSOAPClientTransport($this->Wsdl, $options, $this, $request);
         if (isset($deftimeout)) {
             ini_set('default_socket_timeout', $deftimeout);
         }
         // a hackish way to emulate listMethods calls
         $rname = $request->name();
         if ($rname == 'system.listMethods' || $rname == 'system.methodSignature') {
             $results = $client->__getFunctions();
             if (!is_array($results)) {
                 throw new Exception('Could not parse wsdl into array of functions');
             } else {
                 $mname = '';
                 if ($rname == 'system.methodSignature') {
                     $mname = $request->parameters();
                     $mname = $mname[0];
                 }
                 $results = ggWSDLParser::transformGetFunctionsResults($results, $rname, $mname);
             }
         } else {
             $results = $client->__soapCall($rname, $request->parameters(), array(), array(), $output_headers);
         }
         // phpSoapResponse responses do not parse anything anyway - no need to call this
         //$rawResponse = $client->__getLastResponse();
         //$response->decodeStream( $request, $rawResponse );
         if (is_soap_fault($results)) {
             $response->setValue(new ggWebservicesFault($results->faultcode, $results->faultstring));
         } else {
             if ($this->returnArrays) {
                 $results = $this->toArray($results);
             }
             $response->setValue($results);
         }
         return $response;
     } catch (exception $e) {
         if (isset($deftimeout)) {
             ini_set('default_socket_timeout', $deftimeout);
         }
         if ($this->errorNumber()) {
             $response->setValue(new ggWebservicesFault($this->errorNumber(), $this->errorString()));
         } else {
             if ($e instanceof SoapFault) {
                 $response->setValue(new ggWebservicesFault($e->faultcode, $e->faultstring));
             } else {
                 $response->setValue(new ggWebservicesFault($e->getCode(), $e->getMessage()));
             }
         }
         return $response;
     }
 }