目前,我使用的是try-catch
以確定Web服務是可調用:獲取裏面的對象從數組內容一個try-catch
try {
WebServices::create($this->nameWS);
}
catch (Exception $e) {
var_dump($e);
}
現在,$e
包含一個沿着錯誤信息包含數組的對象如下所示。
注:看似隨機"
下面的第三行,再次接近尾聲。
我敢肯定,你可以看到我想要得到的字符串 - 它是唯一一個我離開的代碼 - 「GetMeService」(這裏面["class"]=>
在[3]
)
object(SoapFault)#304 (8) {
["message:protected"]=>
string(182) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost:8080/examplewsdl' : failed to load external entity "http://localhost:8080/examplewsdl"
"
["string:private"]=>
string(0) ""
["code:protected"]=>
int(0)
["file:protected"]=>
string(71) ""
["line:protected"]=>
int(87)
["trace:private"]=>
array(8) {
[0]=>
array(6) {
["file"]=>
string(71) ""
["line"]=>
int(87)
["function"]=>
string(10) ""
["class"]=>
string(10) ""
["type"]=>
string(2) "->"
["args"]=>
array(2) {
[0]=>
string(49) ""
[1]=>
array(6) {
["trace"]=>
bool(true)
["features"]=>
int(1)
["login"]=>
NULL
["password"]=>
NULL
["proxy_host"]=>
string(13) ""
["proxy_port"]=>
int(80)
}
}
}
[1]=>
array(6) {
["file"]=>
string(71) ""
["line"]=>
int(41)
["function"]=>
string(15) ""
["class"]=>
string(18) ""
["type"]=>
string(2) "->"
["args"]=>
array(2) {
[0]=>
&object(WebServices)#292 (1) {
["_instanceWSCache"]=>
array(1) {
["eva"]=>
array(2) {
["type"]=>
string(4) "php5"
["params"]=>
array(4) {
["proxyhost"]=>
string(13) ""
["proxyport"]=>
int(80)
["wsdl"]=>
string(49) ""
["uri"]=>
string(24) ""
}
}
}
}
[1]=>
string(7) ""
}
}
[2]=>
array(6) {
["file"]=>
string(79) ""
["line"]=>
int(22)
["function"]=>
string(6) ""
["class"]=>
string(18) ""
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(7) ""
}
}
[3]=>
array(6) {
["file"]=>
string(82) ""
["line"]=>
int(218)
["function"]=>
string(6) ""
["class"]=>
string(14) "GetMeService"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
}
["faultstring"]=>
string(182) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost:8080/examplewsdl' : failed to load external entity "http://localhost:8080/examplewsdl"
"
["faultcode"]=>
string(4) "WSDL"
}
無論我嘗試用我的var_dump
替換(例如var_dump($e=>["trace:private"][3]["class"]);
),我都無法訪問該字符串。可能嗎?
這是因爲它是私有的。 – karmafunk