MySoapClient.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. return $response;
  64. }
  65. }