MySoapClient.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. namespace ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap;
  3. use SoapClient;
  4. /**
  5. *
  6. * Created by PhpStorm.
  7. * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
  8. * Date: 27.08.19
  9. * Time: 15:47
  10. * Class MySoapClient
  11. */
  12. class MySoapClient extends SoapClient
  13. {
  14. /**
  15. * @param string $request
  16. * @param string $location
  17. * @param string $action
  18. * @param int $version
  19. * @return string
  20. */
  21. public function __doRequest($request, $location, $action, $version)
  22. {
  23. if(stripos($request, 'DistributionListActionRequest') !== false)
  24. {
  25. $request = str_replace(array('ns1:DistributionListActionRequest', 'xmlns:ns2="urn:zimbra"'), array('ns2:DistributionListActionRequest', 'xmlns:ns2="urn:zimbraAccount"'), $request);
  26. }
  27. logModuleCall(
  28. 'zimbraEmail',
  29. __FUNCTION__,
  30. [
  31. $request,
  32. $location,
  33. $action,
  34. $version
  35. ],
  36. "Debug: request, location, action, version",
  37. time()
  38. );
  39. $exception = null;
  40. try {
  41. $response = parent::__doRequest($request, $location, $action, $version);
  42. }
  43. catch (SoapFault $sf) {
  44. //this code was not reached
  45. $exception = $sf;
  46. }
  47. catch (Exception $e) {
  48. //nor was this code reached either
  49. $exception = $e;
  50. }
  51. if((isset($this->__soap_fault)) && ($this->__soap_fault != null)) {
  52. //this is where the exception from __doRequest is stored
  53. $exception = $this->__soap_fault;
  54. }
  55. logModuleCall(
  56. 'zimbraEmail',
  57. __FUNCTION__,
  58. $exception,
  59. "Debug: response",
  60. time()
  61. );
  62. return $response;
  63. }
  64. /**
  65. * @param string $function_name
  66. * @param array $arguments
  67. * @param array|null $options
  68. * @param null $input_headers
  69. * @param array|null $output_headers
  70. * @return mixed|void
  71. */
  72. public function __soapCall($function_name, array $arguments, array $options = null, $input_headers = null, array &$output_headers = null)
  73. {
  74. logModuleCall(
  75. 'zimbraEmail',
  76. __FUNCTION__,
  77. [
  78. $function_name,
  79. $arguments,
  80. $options,
  81. $input_headers,
  82. $output_headers
  83. ],
  84. "Debug: function_name, arguments, options, input_headers, output_headers",
  85. time()
  86. );
  87. $response = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
  88. logModuleCall(
  89. 'zimbraEmail',
  90. __FUNCTION__,
  91. $response,
  92. "Debug: function_name, arguments, options, input_headers, output_headers",
  93. time()
  94. );
  95. return $response;
  96. }
  97. }