dongtun1683 2014-08-12 09:52 采纳率: 0%
浏览 103
已采纳

如何解析异常错误

I'm working with soap. when I made a call, I used try {} catch {} block. I want to save the exception errors into database. and in order to beautify the codes I parse the errors to my another function here's the sample:

$paramis = array(
                'client' => '225',
                'film_id' => '612',
                'booking' => '2016-02-28',
                'persons' => 1
            );
$puri = 'http://www.filmonschedule.com/Portal/break.asmx?WSDL';
$client = new SoapClient($puri, array('trace' => 1, 'exceptions' => 1));
//var_dump($client);

try {
    $resp = $client->__soapCall('getFilmToBook', array('parameters' => $paramis));
} catch (Exception $e) {
    printErrorMu($e);
}

function printErrorMu($e)
{
    print_r($e);
}

this is the output printErrorMu($e)

SoapFault Object
(
    [message:protected] => System.Web.Services.Protocols.SoapException: No Schedule
   at Portal.Break.getFilmToBook(String portalName, String client, String film_id, String booking, String persons)
    [string:Exception:private] => 
    [code:protected] => 0
    [file:protected] => /var/www/myfilm/test.php
    [line:protected] => 245
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => /var/www/myfilm/test.php
                    [line] => 245
                    [function] => __soapCall
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                            [0] => getFilmToBook
                            [1] => Array
                                (
                                    [parameters] => Array
                                        (
                                            [client] => 225
                                            [film_id] => 612
                                            [booking] => 2016-02-28
                                            [persons] => 1
                                        )

                                )

                        )

                )

        )

    [previous:Exception:private] => 
    [faultstring] => System.Web.Services.Protocols.SoapException: No Schedule
   at Portal.Break.getFilmToBook(String portalName, String client, String film_id, String booking, String persons
    [faultcode] => soap:Server
    [faultactor] => http://www.filmonschedule.com/Portal/break.asmx
    [detail] => stdClass Object
        (
            [exceptionInfo] => No schedule for this booking request
        )

)

but I cannot read the parameter as object/array inside function printErrorMu($e). how to convert the parameter as array or as object so I can access these values of property/key ([message:protected][string:Exception:private][code:protected][file:protected][line:protected][trace:Exception:private][previous:Exception:private]) ?

thank you.

  • 写回答

1条回答 默认 最新

  • duan_2000 2014-08-12 09:56
    关注

    Why you cannot? Use the SoapFault methods:

    $e->getMessage();
    $e->getPrevious();
    ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路