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();
    ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据