Răsfoiți Sursa

revert use new soap client each request, use keepalive false

andre 1 an în urmă
părinte
comite
22f6638157
1 a modificat fișierele cu 27 adăugiri și 50 ștergeri
  1. 27 50
      app/Libs/Zimbra/Components/Api/Soap/Connection.php

+ 27 - 50
app/Libs/Zimbra/Components/Api/Soap/Connection.php

@@ -105,11 +105,33 @@ class Connection implements ConnectionInterface
          */
         list($location, $uri, $params) = $this->getLoginDetails($server, $port, $username, $password, $user,$authToken, $preauth);
 
+        /**
+         *
+         * create new soap client with data
+         */
+        $this->soapClient = new \ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\MySoapClient(null,
+            [
+                'location'       => $location,
+                'uri'            => $uri,
+                'default_socket_timeout' => 10,
+                'trace'          => 1,
+                'exceptions'     => 1,
+                'keep_alive'     => false,
+                'soap_version'   => SOAP_1_2,
+                'style'          => SOAP_RPC,
+                'use'            => SOAP_LITERAL,
+                'stream_context' => stream_context_create(
+                    [
+                        'ssl' => [
+                            'verify_peer'      => false,
+                            'verify_peer_name' => false,
+                        ]])
+            ]
+        );
+
         /**
          * set credential params
          */
-        $this->location = $location;
-        $this->uri = $uri;
         $this->params = $params;
     }
 
@@ -176,29 +198,6 @@ class Connection implements ConnectionInterface
      */
     public function login()
     {
-        /**
-         *
-         * create new soap client with data
-         */
-        $soapClient = new \ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\MySoapClient(null,
-            [
-                'location'       => $this->location,
-                'uri'            => $this->uri,
-                'default_socket_timeout' => 10,
-                'trace'          => 1,
-                'exceptions'     => 1,
-                'soap_version'   => SOAP_1_2,
-                'style'          => SOAP_RPC,
-                'use'            => SOAP_LITERAL,
-                'stream_context' => stream_context_create(
-                    [
-                        'ssl' => [
-                            'verify_peer'      => false,
-                            'verify_peer_name' => false,
-                        ]])
-            ]
-        );
-
         try
         {
             /**
@@ -210,7 +209,7 @@ class Connection implements ConnectionInterface
              *
              * authentication request
              */
-            $result = $soapClient->__soapCall("AuthRequest", $this->params, null, $this->getSoapHeader());
+            $result = $this->soapClient->__soapCall("AuthRequest", $this->params, null, $this->getSoapHeader());
 
             /**
              *
@@ -275,28 +274,6 @@ class Connection implements ConnectionInterface
      */
     public function request($request, $params = [], $options = [])
     {
-        /**
-         *
-         * create new soap client with data
-         */
-        $soapClient = new \ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\MySoapClient(null,
-            [
-                'location'       => $this->location,
-                'uri'            => $this->uri,
-                'default_socket_timeout' => 10,
-                'trace'          => 1,
-                'exceptions'     => 1,
-                'soap_version'   => SOAP_1_2,
-                'style'          => SOAP_RPC,
-                'use'            => SOAP_LITERAL,
-                'stream_context' => stream_context_create(
-                    [
-                        'ssl' => [
-                            'verify_peer'      => false,
-                            'verify_peer_name' => false,
-                        ]])
-            ]
-        );
 
         /**
          * headers
@@ -318,7 +295,7 @@ class Connection implements ConnectionInterface
              *
              * request to api
              */
-            $soapClient->__soapCall(
+            $this->soapClient->__soapCall(
                 $request,
                 $params,
                 $options,
@@ -338,7 +315,7 @@ class Connection implements ConnectionInterface
         /**
          * Zimbra api response
          */
-        $soapRes = $soapClient->__getLastResponse();
+        $soapRes = $this->soapClient->__getLastResponse();
 
         /**
          *