PHP SOAP error catching

后端 未结 7 1332
北恋
北恋 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:02

    Fatal error: SOAP-ERROR: Parsing WSDL Means the WSDL is wrong and maybe missing? so it's not related to soap. And you cannot handle FATAL ERROR with a try catch. See this link : http://ru2.php.net/set_error_handler#35622

    What do you get when you try to access http://192.168.0.142:8080/services/Logon?wsdl in your browser?

    You can check if the WSDL is present like this

    $handle = curl_init($url);
    curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);
    
    $response = curl_exec($handle);
    $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    if($httpCode == 404) {
        /* You don't have a WSDL Service is down. exit the function */
    }
    
    curl_close($handle);
    
    /* Do your stuff with SOAP here. */
    

提交回复
热议问题