![]() |
API ERROR - Printable Version +- webERP Forum (http://www.weberp.org/forum) +-- Forum: webERP Discussion (http://www.weberp.org/forum/forumdisplay.php?fid=1) +--- Forum: Problems / Bugs? (http://www.weberp.org/forum/forumdisplay.php?fid=8) +--- Thread: API ERROR (/showthread.php?tid=816) |
API ERROR - Gamini - 03-14-2013 When i'm ruining below code i'm getting this error - Fatal error: Call to a member function kindOf() on a non-object in C:\wamp\www\webERP\xmlrpc\lib\xmlrpc.inc on line 3310 <?php include '../webERP/xmlrpc/lib/xmlrpc.inc'; //include 'config.inc'; echo '<a href="index.php">Home</a></BR>'; if (isset($_GET['stockid'])) { $_POST['stockid']=$_GET['stockid']; $_POST['submit']='set'; } if (!isset($_POST['submit'])) { echo '<FORM METHOD="post" action=' . $_SERVER['PHP_SELF'] . '>Enter stock id'; echo '<INPUT type="text" name="stockid"></BR>'; echo 'Enter Location ID <INPUT type="text" name="locationid"></BR><input type="Submit" name="submit" value="Get Balance">'; echo '</FORM>'; } else { $stockid = new xmlrpcval($_POST['stockid']); $user = new xmlrpcval('admin'); $password = new xmlrpcval('abc123'); $msg = new xmlrpcmsg("weberp.xmlrpc_GetStockBalance", array($stockid, $user, $password)); $client = new xmlrpc_client('http://localhost/webERP/api/api_xml-rpc.php'); $client->setDebug(2); $response = $client->send($msg); $balances = php_xmlrpc_decode($response->value()); echo "<table border=1>"; if (sizeof($balances)<1) { echo 'oops, an error number '.$balances[0].' has occurred'; } for ($i=0;$i<sizeOf($balances[1]);$i++) { echo "<tr><td>".$balances[1][$i]['loccode']."</td><td>".$balances[1][$i]['quantity']."</td></tr>"; } echo "</table>"; } ?> RE: API ERROR - etabaraz - 03-28-2013 (03-14-2013, 06:06 PM)Gamini Wrote: When i'm ruining below code i'm getting this error - Fatal error: Call to a member function kindOf() on a non-object in C:\wamp\www\webERP\xmlrpc\lib\xmlrpc.inc on line 3310 Hi, what information did you get before this error message. With debug level at 2 there was probably a lot of information sent. Can you either post it here, and/or email it directly to me at tim@weberpafrica.com. This error means that webERP is returning some information that is not correctly formed xml, probably meaning that it is generating an error message. I take it the userid/password combination you are sending is a genuine webERP login? Thanks Tim RE: API ERROR - Gamini - 04-03-2013 Pls find below the error. Home ---SENDING--- POST /webERP/api/api_xml-rpc.php HTTP/1.0 User-Agent: XML-RPC for PHP 3.0.0.beta Host: localhost Accept-Encoding: gzip, deflate Accept-Charset: UTF-8,ISO-8859-1,US-ASCII Content-Type: text/xml Content-Length: 287 <?xml version="1.0"?> <methodCall> <methodName>weberp.xmlrpc_GetStockBalance</methodName> <params> <param> <value><string>upul</string></value> </param> <param> <value><string>admin</string></value> </param> <param> <value><string>abc123</string></value> </param> </params> </methodCall> ---END--- ---GOT--- HTTP/1.1 200 OK Date: Wed, 03 Apr 2013 08:15:21 GMT Server: Apache/2.4.2 (Win64) PHP/5.4.3 X-Powered-By: PHP/5.4.3 Set-Cookie: webERPapi=io8vejlf87pnoab33agqcec851; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Length: 0 Connection: close Content-Type: text/html ---END--- HEADER: date: Wed, 03 Apr 2013 08:15:21 GMT HEADER: server: Apache/2.4.2 (Win64) PHP/5.4.3 HEADER: x-powered-by: PHP/5.4.3 HEADER: set-cookie: webERPapi=io8vejlf87pnoab33agqcec851; path=/ HEADER: expires: Thu, 19 Nov 1981 08:52:00 GMT HEADER: cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 HEADER: pragma: no-cache HEADER: content-length: 0 HEADER: connection: close HEADER: content-type: text/html COOKIE: webERPapi=io8vejlf87pnoab33agqcec851 XML error at line 1, check URL ( ! ) Fatal error: Call to a member function kindOf() on a non-object in C:\wamp\www\webERP\xmlrpc\lib\xmlrpc.inc on line 3310 Call Stack # Time Memory Function Location 1 0.0006 261856 {main}( ) ..\file.php:0 2 0.0777 1032024 php_xmlrpc_decode( ) ..\file.php:32 Thank you. RE: API ERROR - etainsee - 04-03-2013 Hi, The crucial part of your output is here: (04-03-2013, 06:27 PM)Gamini Wrote: HEADER: date: Wed, 03 Apr 2013 08:15:21 GMT You can see that the content length returned is zero bytes, but that you got a HTTP/1.1 200 OK reply from the server so that you know the connection was made fine. Here is the output for the same function call in my tutorial: HEADER: date: Wed, 03 Apr 2013 10:16:02 GMT HEADER: server: Apache/2.2.22 (Ubuntu) HEADER: x-powered-by: PHP/5.4.6-1ubuntu1.2 HEADER: set-cookie: KwaMojaapi=7p92iirlt6i26mgmpj2ssjs711; path=/ HEADER: expires: Thu, 19 Nov 1981 08:52:00 GMT HEADER: cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 HEADER: pragma: no-cache HEADER: vary: Accept-Encoding HEADER: content-encoding: gzip HEADER: content-length: 196 HEADER: connection: close HEADER: content-type: text/xml COOKIE: KwaMojaapi=7p92iirlt6i26mgmpj2ssjs711 As you can see it returned 196 bytes of info. My guess is going to be that it is because you don't have these two lines in your output: HEADER: vary: Accept-Encoding HEADER: content-encoding: gzip meaning that you don't have the mod_deflate apache module enabled. Can you enable this (google for how to do it) restart apache, and try again. Thanks Tim |