PHP SOAP error catching

后端 未结 7 1320
北恋
北恋 2020-12-14 07:49

I\'m getting desperate, all I want is simple error handling when the PHP SOAP Web Service is down to echo an error message login service down. Please help me!

7条回答
  •  死守一世寂寞
    2020-12-14 08:09

    I ended up handling it this way:

           libxml_use_internal_errors(true);
            $sxe = simplexml_load_string(file_get_contents($url));
            if (!$sxe) {
                return [
                    'error' => true,
                    'info' => 'WSDL does not return valid xml',
                ];
            }
            libxml_use_internal_errors(false);
    

    Do your soap call after this check.

提交回复
热议问题