错误:“解析WSDL:无法加载”然后执行某些操作

时间:2016-06-17 23:02:21

标签: php xml soap wsdl

我的SoapClient有时会下降。

// send request
$client = new SoapClient("http://XXXXXXXXX.org/NowPlaying.asmx?WSDL");
$result = $client->GetNowPlaying();

// get array of items
$arr = $result->GetNowPlayingResult->PlayerItem;

在那些时候,我想展示错误消息的内容。我做了很多if / else语句,但是一切正常。

你能帮助我吗?

1 个答案:

答案 0 :(得分:1)

您是否尝试过try / catch

try {
    // send request
    $client = new SoapClient("http://XXXXXXXXX.org/NowPlaying.asmx?WSDL");
    $result = $client->GetNowPlaying();

    // get array of items
    $arr = $result->GetNowPlayingResult->PlayerItem;
} catch (Exception $e) {
    echo 'Sorry, there was a problem!<br><br>';
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}