Php 遇到Ecircle SOAP API错误时重定向
我正在试验EcircleSOAPAPI,目前我正在使用它向在我的网站上注册的新用户发送消息。我正在尝试做一个错误处理,这样当API失败时,该函数将向我发送一封包含错误和用户id/电子邮件的电子邮件,然后返回到主函数并继续它的工作。这样,我就可以知道问题所在,用户就可以在没有任何干扰的情况下继续他们正在做的事情。下面是一个函数示例:Php 遇到Ecircle SOAP API错误时重定向,php,api,soap,Php,Api,Soap,我正在试验EcircleSOAPAPI,目前我正在使用它向在我的网站上注册的新用户发送消息。我正在尝试做一个错误处理,这样当API失败时,该函数将向我发送一封包含错误和用户id/电子邮件的电子邮件,然后返回到主函数并继续它的工作。这样,我就可以知道问题所在,用户就可以在没有任何干扰的情况下继续他们正在做的事情。下面是一个函数示例: function lookupuserbyemail($userinput) { $ns = "http://webservices.ecircleag.c
function lookupuserbyemail($userinput) {
$ns = "http://webservices.ecircleag.com/rpcns";
$client = new soapclient('http://webservices.ecircle-ag.com/soap/ecm.wsdl');
$logonparams = array('realm' => "http://email.mywebsite.com",
'user' => "admin@hotmail.com",
'passwd' => "12345");
// check if logon was successful
$result = $client->logon($logonparams);
if (is_soap_fault($result)) {
sendMsgToMe();
return;
}
$sessionid = $result->logonReturn;
// logon ok, now call the function
$params = array('email' => $userinput,
'session' => $sessionid);
$result = $client->lookupUserByEmail($params);
//check if the function was executed properly
if (is_soap_fault($result)) {
$result = "error";
return $result;
}
// print the result
$userinfo = htmlspecialchars($result->lookupUserByEmailReturn);
// now logout
$params = array('session' => $sessionid);
$client->logout($params);
if (is_soap_fault($result)) {
$result = "error";
return $result;
}
return $userinfo;
}
根据他们位于的wiki,以下代码用于检测错误或API函数失败时的代码:
$result = $client->logon($logonparams);
if (is_soap_fault($result)) {
sendMsgToMe();
return;
}
但情况并非如此,它只是崩溃,而不是报告错误,用户会看到:
Uncaught SoapFault exception: [soapenv:Server.userException] com.ecircleag.webservices.EcMException: Error: blablablabla.
显然,这不是很好,因为如果ecircle服务关闭,用户将无法继续,因此我想知道,即使记录了SOAP错误,my代码是否可能继续运行
谢谢:)