I got a code that interacts with a soap client that I enclose with a try catch statement. But it seems that the try catch statement could not catch the error as the script would fail. I would like the code to continue the execution even after the error.

我得到了一个与soap客户端交互的代码,我将其与try catch语句一起包含在内。但似乎try catch语句无法捕获错误,因为脚本会失败。我希望代码在错误发生后继续执行。

The error is [error] [php]SoapClient::SoapClient(): failed to open stream: Connection timed out

错误是[错误] [php] SoapClient :: SoapClient():无法打开流:连接超时

How to better handle the error without stopping the execution of the code?

如何更好地处理错误而不停止执行代码?

Below is the code.

以下是代码。

try{

   $client = new SoapClient($url, $config);

   $result = $client->RemoteMethod(
                array( "param1" =>$data1 
                "param2" => $data2
                "param3" => $data3
                )
            );

    $response = objectToArray($result); 

}catch(Exception $e){

}

2 个解决方案

#1


1

What is the current namespace? Try changing the catch to:

什么是当前的命名空间?尝试将捕获更改为:

}catch(\Exception $e){

(Note the backslash.)

(注意反斜杠。)

更多相关文章

  1. fgetcsv()错误地将双引号添加到第一行的第一个元素
  2. CakePHP错误:在Acl中找不到类'String'
  3. 错误1452:无法添加或更新子行:外键约束失败
  4. 韩顺平_php从入门到精通_视频教程_学习笔记_源代码图解_PPT文档
  5. 【MySQL 技巧分享】 mysql -e 加 v 简化代码
  6. Oracle相当于MySQL代码“插入虚拟”以返回错误消息
  7. 登录使用PHP并´t显示任何html代码
  8. MySQL添加外键错误1215
  9. 在SQL中声明@变量返回错误

随机推荐

  1. css让背景图片拉伸填充的属性
  2. 解决FCKEditor编辑器在浏览器返回时显示h
  3. 关于struts漏洞之---/struts/webconsole.
  4. 图像未加载到HTML页面的jQuery load()中
  5. 如何在HTML标记上打印/显示动态值?
  6. css+html实现自适应宽度的菜单学习
  7. 用HTML做的简单的个人简历
  8. 具有不间断空格的呈现字符串
  9. 经常使用的20个css高级技巧(下)
  10. 创建mailto超链接,该超链接将在Outlook中