deviloper
deviloper

Reputation: 7240

How to enforce custom exception when getting no soap response

I am trying to handle the possible exceptions that I might get from a soap service. Sometimes I get the following:

0: Error Fetching http headers
Exception Type:   SoapFault

The thing is that when I get no response headers, the exception page is displayed on the page. I want to avoid redirection to this default exception page, instead I want to display a custom message in an alert.

    $url = $this->domain . self::TASK_SERVICE;
        $options = [
            'soap_version' => SOAP_1_1,
            'request_timeout' => 5,
        ];

        return $this->withErrorHandling(function () use ($url, $options) {
            try {
                $this->taskServiceSoapClient = SoapHelper::GetSuperClient($url, $options);

                return $this->taskServiceSoapClient;
            } catch (SoapFault $e) {
                throw new MyCustomException('Remote: service not available', 500, $e);
            }
        });

But it never reaches to the catch block.

Upvotes: 0

Views: 12

Answers (0)

Related Questions