MySoapClient.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. $exception = null;
  28. try {
  29. $response = parent::__doRequest($request, $location, $action, $version);
  30. }
  31. catch (SoapFault $sf) {
  32. //this code was not reached
  33. $exception = $sf;
  34. }
  35. catch (Exception $e) {
  36. //nor was this code reached either
  37. $exception = $e;
  38. }
  39. if((isset($this->__soap_fault)) && ($this->__soap_fault != null)) {
  40. //this is where the exception from __doRequest is stored
  41. $exception = $this->__soap_fault;
  42. logModuleCall(
  43. 'zimbraEmail',
  44. __FUNCTION__,
  45. $exception,
  46. "Debug: response",
  47. $result
  48. );
  49. }
  50. return $response;
  51. }
  52. /**
  53. * @param string $function_name
  54. * @param array $arguments
  55. * @param array|null $options
  56. * @param null $input_headers
  57. * @param array|null $output_headers
  58. * @return mixed|void
  59. */
  60. public function __soapCall($function_name, array $arguments, array $options = null, $input_headers = null, array &$output_headers = null)
  61. {
  62. $response = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
  63. logModuleCall(
  64. 'zimbraEmail',
  65. __FUNCTION__,
  66. [ $function_name, $arguments, $options ],
  67. 'debug',
  68. $response
  69. );
  70. return $response;
  71. }
  72. }