MySoapClient.php 2.3 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. logModuleCall(
  40. 'zimbraEmail',
  41. __FUNCTION__,
  42. $request,
  43. $action,
  44. $response
  45. );
  46. if((isset($this->__soap_fault)) && ($this->__soap_fault != null)) {
  47. //this is where the exception from __doRequest is stored
  48. $exception = $this->__soap_fault;
  49. logModuleCall(
  50. 'zimbraEmail',
  51. __FUNCTION__,
  52. $exception,
  53. "Debug: response",
  54. $result
  55. );
  56. }
  57. return $response;
  58. }
  59. /**
  60. * @param string $function_name
  61. * @param array $arguments
  62. * @param array|null $options
  63. * @param null $input_headers
  64. * @param array|null $output_headers
  65. * @return mixed|void
  66. */
  67. public function __soapCall($function_name, array $arguments, array $options = null, $input_headers = null, array &$output_headers = null)
  68. {
  69. $response = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
  70. return $response;
  71. }
  72. }