3

I've got the following function:

public function query($sql)
{
    $query = array(
    "queryString"=>$sql
    );
    $queryWrapper = array(
    "query"=>$query
    );

    try {
        $result = $this->_client->__soapCall("query", $queryWrapper, null, $this->_header);
    } catch (SoapFault $e) {
      $this->_client->__getLastResponse();
    }
    return $result;
}

The problem is that I can use var_dump('anything');exit; before the __soapCall(), and I see 'anything'. But if I var_dump('stuff');exit; AFTER the __soapCall(), I get just a blank page. I var_dump('something');exit; in the catch, but I don't see that. It's still just a blank page. My question is, what could be causing this? I would think that if the table in my query didn't exist, or something was wrong with my query at all, I'd get some sort of error. But I'm getting absolutely squat all.

PiousVenom
  • 6,888
  • 11
  • 47
  • 86
  • Possible duplicate of https://stackoverflow.com/questions/6374345/php-soapfault-not-caught-by-exception-handlers Please check, I believe your problem is solved in answers – Dmytro Zasiadko Aug 01 '18 at 06:34
  • @DmytroZasiadko: I've tried both answers, and get the same results I've listed above. – PiousVenom Aug 01 '18 at 16:22
  • So did you try to enable exceptions passing `"exceptions" => true` to soap client constructor and catching `\Exception $e` at the same time? – Dmytro Zasiadko Aug 01 '18 at 22:22
  • @DmytroZasiadko: that's correct. – PiousVenom Aug 01 '18 at 22:39
  • Keep in mind that if you see a blank page, it's probably that the server is responding that. Try to find the status of the transaction. If you have 500 for instance, server is throwing an error, if you have a 200, server is responding that, void. – Emeeus Aug 02 '18 at 02:20
  • did you try `catch (\SoapFault $e)`? because if your function in class with namespace php will try to find SoapFault class within this namespace – Denis Alimov Aug 02 '18 at 10:45
  • If you are seeing a blank page and post-call var_dump() is not being displayed, it's possibly due to a premature script termination inside your soap call. [Try temporarily activating error reporting](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) (add the code somewhere before your call) to see if you can see on-screen exception reporting. – alariva Aug 05 '18 at 00:14
  • In your catch do `var_dump($e)`. I assume it will contain something indicating what the issue is. – Cameeob2003 Aug 05 '18 at 07:06
  • error_reporting(E_ALL); ini_set('display_errors', 1); Tray adding this two lines in start of the function and try again i think in function there is warning or errors so its stoping php script – Harsh Virani Aug 06 '18 at 08:15

1 Answers1

0

I would try these scenarios:

1. Correct Exceptions

Is $this->_client instance of standard \SoapClient? If not, there could be different exceptions thrown that your catch ignores. If you are on PHP 7.0 and above try catching \Throwable if on older versions try catching \Exception.

2. Run in isolation

If the problem persists it would be better to isolate this function from your codebase and try running it separately. You can even try online tools like 3v4l.

3. Xdebug

If you still cannot find the cause, it is best to trace the issue with xdebug. You can find a simple setup tutorial for Docker and PhpStorm here: https://medium.com/@pablofmorales/xdebug-with-docker-and-phpstorm-786da0d0fad2

Jan Richter
  • 1,976
  • 4
  • 29
  • 49