예제 #1
0
 public function clientAction()
 {
     //        return;
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $starttime = $mtime;
     ini_set("soap.wsdl_cache_enabled", 0);
     $client = new Zend_Soap_Client("http://sms.loc/ws/sms?wsdl");
     try {
         $data = $client->text('C22CWF', "a3gtniwerfawkdhnako", '48510066024', 'test');
         debug($data);
     } catch (SoapFault $s) {
         var_dump("SOAP Fault: (faultcode: {$s->faultcode}, faultstring: {$s->faultstring})");
     } catch (Exception $e) {
         print "EXC:\n";
         var_dump($e->getMessage());
     }
     if ($client instanceof Zend_Soap_Client) {
         print "<pre>\n";
         print "Request :\n" . htmlspecialchars($client->getLastRequest()) . "\n";
         print "Response:\n" . htmlspecialchars($client->getLastResponse()) . "\n\n";
         print "Request:\n" . $client->getLastRequestHeaders() . "\n";
         print "Response:\n" . $client->getLastResponseHeaders() . "\n";
         print "</pre>";
     }
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $endtime = $mtime;
     $totaltime = $endtime - $starttime;
     echo "<br /><h3>This page was created in " . $totaltime . " seconds</h3>";
 }
예제 #2
0
 public function performRequest($wsdl, $operation, $params, $options = array('encoding' => 'UTF-8'), $fullReponse = false)
 {
     if (!extension_loaded('soap')) {
         return 'Extension SOAP not found';
     }
     if (!isset($options['soap_version'])) {
         $options['soap_version'] = SOAP_1_1;
     }
     $client = new Zend_Soap_Client($wsdl, $options);
     $soap_params = array();
     foreach ($params as $param_name => $param_value) {
         preg_match('/^(.*)\\:(.*)$/', $param_name, $matches);
         if (count($matches) == 3) {
             if (!isset($soap_params[$matches[1]])) {
                 $soap_params[$matches[1]] = array();
             }
             $soap_params[$matches[1]][$matches[2]] = $param_value;
         } else {
             $soap_params[$param_name] = $param_value;
         }
     }
     try {
         // Set (Session) cookies before the call
         if ($this->allowCookies) {
             if (is_array($this->cookies)) {
                 foreach ($this->cookies as $cookieName => $cookieValue) {
                     $client->setCookie($cookieName, $cookieValue[0]);
                 }
             }
         }
         // Perform the SOAP request
         $result = call_user_func_array(array($client, $operation), $soap_params);
         // Pick up any new cookies from the server
         if ($this->allowCookies) {
             $last_response = $client->getLastResponseHeaders();
             $soapClt = $client->getSoapClient();
             $this->cookies = array_merge($soapClt->_cookies, $this->cookies);
         }
     } catch (SoapFault $e) {
         trigger_error($e->getMessage());
         return $e->getMessage();
     }
     // Unless the full response result is specified, only reply the returned result, and not the "out" parameter results
     if (is_object($result) && !$fullReponse) {
         $result_name = $operation . 'Result';
         if (isset($result->{$result_name})) {
             return $result->{$result_name};
         }
     }
     return $result;
 }