API (xmlrpc) problem - 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 (xmlrpc) problem (/showthread.php?tid=533) Pages:
1
2
|
API (xmlrpc) problem - SMT Corp - 02-11-2013 I'm trying to connect/login with the API following the conventions in the example on this page: http://www.weberp.org/wiki/APIDocumentation Something is going wrong when I call xmlrpcval to try to set the values of the $Parameters array, I'm not sure why because I haven't strayed much from the example above. Code: <?php The location of the xmlrpc include is correct (I've put echos in there to verify and they print out fine) and the URL for api_xml-rpc.php is good (not that I'm even getting that far yet.) I have all of the contents of the "xmlrpc" folder in the proper place within the folder of the php file I've posted above (sitting on the same web server as the webERP installation but in a different folder under the root.) My "We've made it this far!" prints, but "This doesn't show up!", well, doesn't show up, and the var_dump doesn't show either. I'm not sure if my 'DatabaseName' parameter key is correct but at this point all I'm trying to do is format these parameters with xmlrpcval and this seems to be stopping PHP parsing. I must be missing a very simple step but I don't see anything going on in the example that I'm failing to do here. Can anybody set me straight? I'm running php version 5.3.5 on the web server, if that matters. Thank you for any help! RE: API (xmlrpc) problem - phil - 02-12-2013 Check out your web-server error log - looks like there may be some parse error .. I am not sure that echoing out variables works with the xml-rpc script - I know that debugging the API is miserable. I'd say the web-server error log will have the answer though. RE: API (xmlrpc) problem - phil - 02-13-2013 Apparently echoing out variables from an API script defeats the code in: Code: include ("xmlrpc/lib/xmlrpc.inc"); So you must remove the echos from your script - your script doesn't actually call any API methods - need to look again at the example at: http://www.weberp.org/wiki/APIDocumentation RE: API (xmlrpc) problem - SMT Corp - 02-14-2013 Thanks for the info, Phil. I copied the example you linked verbatim, and I added DVD-TOPGUN to my inventory and gave it a quantity of 5 at my only location. The only change I made to the code from the example is the $ServerURL variable, which I've pointed to the appropriate location on my server, and the username/password combo matches already so no need to mess with that. It's not giving me anything back, if I view source it's completely blank. Regarding the echos before calling xmlrpcval, the example you link is echoing as well (just the opening html tags and such.) Even if I comment out the html echos, I'm getting no "location x has 5 on hand" or anything like that. I'm thinking something is fundamentally weird with either my PHP setup or the example, and I'm not enough of a PHP guru to really pin it down. I know this is not your code, but looking into xmlrpc.inc, I see xmlrpcval is a class unto itself, with a constructor function xmlrpcval. Forgive my PHP newbishness (at least when it comes to the class/object stuff) but my Java-trained brain is inclined to think just calling xmlrpcval like a regular function in the example will not work. Again, this is me stuck in Java mode, so maybe this is kosher in PHP? RE: API (xmlrpc) problem - phil - 02-14-2013 There is some information on the mailing lists archives which may be of some use - I recall I had similar difficulties getting going - can't sadly recall the answer sorry - have a look through some of these old postings though - maybe of some help. I know setting the debug level produced some output which enabled me to figure out what was going on. http://sourceforge.net/mailarchive/message.php?msg_id=22256123 RE: API (xmlrpc) problem - SMT Corp - 02-19-2013 Well, I've gotten a little farther under the hood with this and I've made some progress, but I'm hitting another weird snag that I can't explain. The problem appears to be in xmlrpc-land. It looks like there is a flaw in the example at: http://www.weberp.org/wiki/APIDocumentation This kind of thing does not work: $Parameters['StockID'] = xmlrpcval('DVD-TOPGUN'); It should be: $Parameters['StockID'] = new xmlrpcval('DVD-TOPGUN'); (as it is in the mailing list post you linked, thanks Phil!) xmlrpcval is a class, not a function, so an object needs to instantiated with "new" to call the constructor function xmlrpcval. Soooo, having made that adjustment, I build the $Parameters array of xmlrpcval objects, which works fine. Doing a var_dump on it, I get: Code: array(3) { This looks perfect. But here's where things get weird: $msg = new xmlrpcmsg("weberp.xmlrpc_GetStockBalance", $Parameters); Then a var_dump of $msg looks like this: Code: object(xmlrpcmsg)#4 (5) { What happened to my parameters? So digging into xmlrpc, here is the constructor for xmlrpcmsg: Code: function xmlrpcmsg($meth, $pars=0) NOTE: I have tried getting rid of the "=0" after $pars, no effect. So, we follow the code to addParam, which looks like this: Code: function addParam($par) is_object($par) and is_a($par, 'xmlrpcval') are both returning false. I'm a little lost as to why that would be... It's looking like this isn't really a webERP issue at this point, but I'd appreciate it if anyone who has run into anything similar could point me in the right direction here. RE: API (xmlrpc) problem - phil - 02-19-2013 Sorry this is too tricky for me ... I will have a play and see if the example I published still works for me!! If you run it without the var_dumps do you get any output from the call?? The API is definitely alive and well though as it is working with my POS system. I have updated my example in the docs to use the new keyword - thanks for the feedback. Did you ever play with the example scripts that Tim published that are downloadable from the wiki page? edit: The link didn't work - just fixed it http://www.weberp.org/wiki/uploads/ScreenShotUploads/xmlrpc.zip Tim's code looks like: Code: <?php RE: API (xmlrpc) problem - SMT Corp - 02-26-2013 I tried Tim's example - there's a little glitch in the code of his that you posted, the submit button needs a closing ">". I'm getting the same kind of results as before, it seems. With no echos at all, letting Tim's code do its thing (with debuglevel set to 2), this is the output I get: Code: ---SENDING--- If I do a view source, the <table border=1></table> is at the bottom but there is no "oops, an error number." The $balances array has a size of 1, should the if statement therefore be if (sizeof($balances)<=1) instead of <1? RE: API (xmlrpc) problem - phil - 02-26-2013 If you run your client against the demo at http://www.weberp.org/weberp/api/api_xml-rpc.php does it work? Can you run webERP ok on http://webtest/webERP/ ? No apache protection or something ? I feel as though I have had this error myself but cannot recall what it was.... sorry. RE: API (xmlrpc) problem - SMT Corp - 02-26-2013 Ahh, interesting, when I point to the instance of the API on your domain and search for inventory items in your demo instance, I DO get results back as expected. I'm able to run webERP at http://webtest/webERP/ just fine, it doesn't look like a folder permissions thing, but I'll try to investigate that possibility further. Suspicions/fears confirmed, I guess this is something to do with xmlrpc on my end. This is all kind of new to me, I'm used to using JSON for just about everything like this. |