PHP SoapFault not caught by exception handlers

后端 未结 2 1601
太阳男子
太阳男子 2020-12-31 02:29

I am new to PHP exception handling and SOAP. For some reason I cannot catch a SoapFault. I don\'t know why. The soap server is not mine.

try { 
    $contact_         


        
2条回答
  •  [愿得一人]
    2020-12-31 03:29

    The problem turned out to be my SoapClient declaration. There is an exceptions parameter that must be set in order for the exceptions to trigger.

    $objSoapClient = new SoapClient('https://mywebservice.com/foo.wsdl', array(
        "trace" => false,  
        "exceptions" => true,     // <-------------- This!!!                                               
        'login' => 'username',    //username
        'password' => 'password', //password
        'features' => SOAP_SINGLE_ELEMENT_ARRAYS + SOAP_USE_XSI_ARRAY_TYPE 
    ));
    

提交回复
热议问题