Explorar o código

use new soap client each request

andre hai 1 ano
pai
achega
7b1493dd99
Modificáronse 1 ficheiros con 51 adicións e 27 borrados
  1. 51 27
      app/Libs/Zimbra/Components/Api/Soap/Connection.php

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

@@ -105,32 +105,11 @@ 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,
-                '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;
     }
 
@@ -197,6 +176,29 @@ 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
         {
             /**
@@ -208,7 +210,7 @@ class Connection implements ConnectionInterface
              *
              * authentication request
              */
-            $result = $this->soapClient->__soapCall("AuthRequest", $this->params, null, $this->getSoapHeader());
+            $result = $soapClient->__soapCall("AuthRequest", $this->params, null, $this->getSoapHeader());
 
             /**
              *
@@ -273,6 +275,28 @@ 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
@@ -294,7 +318,7 @@ class Connection implements ConnectionInterface
              *
              * request to api
              */
-            $this->soapClient->__soapCall(
+            $soapClient->__soapCall(
                 $request,
                 $params,
                 $options,
@@ -314,7 +338,7 @@ class Connection implements ConnectionInterface
         /**
          * Zimbra api response
          */
-        $soapRes = $this->soapClient->__getLastResponse();
+        $soapRes = $soapClient->__getLastResponse();
 
         /**
          *
@@ -328,7 +352,7 @@ class Connection implements ConnectionInterface
             ->setXmlResponse($soapRes)
             ->response();
     
-            return $response;
+        return $response;
     }
 
     /**