【发布时间】:2011-08-05 07:21:12
【问题描述】:
我快绝望了,我想要的只是当 PHP SOAP Web 服务关闭时进行简单的错误处理以回显错误消息登录服务关闭。请帮帮我!
目前它仍在显示错误(以及警告...):
Fatal error: SOAP-ERROR: Parsing WSDL
这是脚本:
<?php
session_start();
$login="0000000000000nhfidsj"; //It is like this for testing, It will be changed to a GET
$username = substr($login,0,13); //as password is always 13 char long
//(the validation is done int he javascript)
$password = substr($login,13);
try
{
ini_set('default_socket_timeout', 5); //So time out is 5 seconds
$client = new SoapClient("http://192.168.0.142:8080/services/Logon?wsdl"); //locally hosted
$array = $client->login(array('username'=>$username,
'password'=>$password));
$result = $array->return;
}catch(SoapFault $client){
$result = "0";
}
if($result == "true")//as this would be what the ws returns if login success
{
$_SESSION['user'] = $login;
echo "00";
}
else
{
echo "01 error: login failed";
}
?>
【问题讨论】:
-
老实说,SOAP 扩展中的任何致命错误都应该报告为错误,因为您的代码不会导致致命错误。如您所料,404 WSDL 应该是 SoapFault。