NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How to stop/hide NuSoap error messages and warnings


Joined: 22 Feb 2007
Posts: 9
Reply with quote
Hi there,

guess this is pretty trivial. But haven't found any answer to this yet. How can I hide the the error messages NuSoap shows me when for example a SQL query is not correct? In the moment it does display error message plus SQL query for everyone visible with the XML Response.

Thanks for any hints.
View user's profileFind all posts by luftikus143Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
you have to return SOAP exception in this case and set its fields with error info.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 22 Feb 2007
Posts: 9
Reply with quote
dmitri wrote:
you have to return SOAP exception in this case and set its fields with error info.


Hmm, thanks a lot for this. I've looked around, but don't really understand what you mean.

Basic problems are being handled like this:
Code:
      // number of rows returned
      $numRows2 = pg_num_rows($results2);
      
      if (!$numRows2)
      {
         return new soap_fault('Server', '', 'No data found!');
      }


But I don't see why in any case SOAP is supposed to spit out the SQL query. Which it does if the SQL is wrong:

Code:
HTTP/1.1 200 OK
Date: Tue, 03 Nov 2009 09:31:04 GMT
Server: Apache/2.2.11 (Unix) PHP/5.2.8
X-Powered-By: PHP/5.2.8
Content-Length: 843
Connection: close
Content-Type: text/html

<br />
<b>Warning</b>:  pg_query() [<a href='function.pg-query'>function.pg-query</a>]: Query failed: ERROR:  syntax error at or near &quot;ORDER&quot;
LINE 10:       (d.year_start = 2006 )  AND d.id_country =  ORDER BY 1...
                                                           ^
QUERY: 
               SELECT
                  COALESCE(c.name, '') AS name,
                  d.year_start AS year,
                  d.value AS value
               FROM
                   cereals_production AS d
               RIGHT JOIN
                  countries_view AS c ON c.id = d.id_country    WHERE
                  (d.year_start = 2006 )  AND d.id_country =  ORDER BY 1,2; in <b>/www/xxxx.php</b> on line <b>335</b>
<br />
<br />
<b>Catchable fatal error</b>:  Object of class soap_fault could not be converted to string in <b>/www/etc/nusoap/lib/nusoap.php</b> on line <b>3615</b>
<br />


How can I suppress this kind of warning? Thanks a lot for any help/adivce!

Stef
View user's profileFind all posts by luftikus143Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
How can I suppress this kind of warning?


1) don't display the errors:
ini_set('display_errors', 'off');

2) wrap the function call that triggers exception in try-catch block:

Code:
try {
  pg_query(...);
}
catch (Exception $e) {
  return new soap_fault('Server', '', $e->getMessage());
}
// normal execution below...


3) if you have php_soap extension loaded but want to use nusoap library, you have to use nusoap_fault class instead of soap_fault

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 22 Feb 2007
Posts: 9
Reply with quote
Thanks a lot. Very helpful, this!
View user's profileFind all posts by luftikus143Send private message


Joined: 22 Feb 2007
Posts: 9
Reply with quote
Sorry, me again. It's strange, because I'd say I have coded it the way you say:

Code:
            // check if rows are returned   
            if ((!$numRows) OR ($numRows == 0))
            {
               return new soap_fault('Server', '', 'No results found. Please choose an earlier date!');
            }


But then I get a "<b>Catchable fatal error</b>: Object of class soap_fault could not be converted to string in <b>/www/etc/nusoap/lib/nusoap.php</b> on line <b>3615</b>" message.

And using nusoap_fault doesn't work either: "<b>Fatal error</b>: Class 'nusoap_fault' not found in <b>/xxx/xxx_data_update_ws.php</b> on line <b>181</b>"

Thanks for any help!
View user's profileFind all posts by luftikus143Send private message
How to stop/hide NuSoap error messages and warnings
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic