Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 3
1.1 Beta Webservices API Problems
 
Suzy
Jr. Member
 
Total Posts:  6
Joined:  2008-07-10
 

I am still not getting results.  Do I need to download the api or something?  I have no api subdirectory.  What directory should I be running this from?
Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
JKwan13
Member
 
Total Posts:  63
Joined:  2008-06-12
 

Are you running the latest 1.1-trunk SVN release? I’ve only had success when using the latest release.

About the directory, your code can be run from any directory as long as you correctly put in the right directory for magento.

For example if you were running your script inside the magento directory (or whereever you installed it), it would be like this:

require_once('app/Mage.php');

If you were one directory above “magento”, then the code would like this:

require_once('magento/app/Mage.php');

In my case, my code was in another directory, so I had to back out of it, using “..”, and then I was able to see my “magento-b2” directory which I renamed it to, so it looked like this:

require_once('../magento-b2/app/Mage.php');

For the SoapClient connection, my code was this:

$client = new SoapClient('http://localhost/magento-b2/api/soap/?wsdl');
As you can see, I installed my on my own server, in the “magento-b2” directory, which might not be the same as yours.

As for the api subdirectory, I’m still not quite sure how that works.  It has something to do with the fact that you have to intialize the magento environment, and therefore you can see these.
It may be in app/code/core/Mage/Api/etc (Sorry, something like that, I’m not at the computer right now)

If you post the error you are getting, I may be able to help further, but I’m just learning how to use this as well. I’m sure there are other people that know much more than me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
JKwan13
Member
 
Total Posts:  63
Joined:  2008-06-12
 

I was looking around at the API docs and I’ve never really looked too much into the “Create your own API” section, since I had no desire to create my own, I didn’t want to do that.  But I did find out where the API is stored in Magento.

For example:
Category: app\code\core\Mage\Catalog\Model\Category\Api.php
Product: app\code\core\Mage\Catalog\Model\Product\Api.php
Customer: app\code\core\Mage\Customer\Model\Customer\Api.php

But, having the API documentation means we shouldn’t have to look at the code, but the documentation is lacking in the method details.

I also just checked, I see that Killoff just updated the Category API.  Thanks Killoff, much appreciated, especially the sample code!  I was struggling to use them, especially the category.tree method, now with your code, I understand.  Thanks again!

 
Magento Community Magento Community
Magento Community
Magento Community
 
brendanb
Mentor
 
Total Posts:  1093
Joined:  2008-07-16
London, United Kingdom
 

hi all,

FYI ive just installed 1.1 (Stable) upgrade from 1.1 Beta and recieved a new error when trying to create a new role or user

ive logged a new bug #6014

cheers
brendan

 
Magento Community Magento Community
Magento Community
Magento Community
 
JKwan13
Member
 
Total Posts:  63
Joined:  2008-06-12
 

@Killoff

Your code for the categories give me a infinite loop.  Some reason the recursion isnt stopping when I use this:

function getSomeRandomCategory(&$categories$targetLevel$currentLevel 0{
    
if (count($categories)==0{
        
return false;
    
}
    
if ($targetLevel == $currentLevel{
        
return $categories[rand(0count($categories)-1)];
    
else {
        
return getSomeRandomCategory($categories[rand(0count($categories)-1)]['children']$targetLevel 1);
    
}    
}
 
$proxy 
= new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId $proxy->login('apiUser''apiKey');
$allCategories $proxy->call($sessionId'category.tree'); // Get all categories.
 
// select random category from tree
while (($selectedCategory getSomeRandomCategory($allCategories3)) === false{}

Also, I’m having problems creating a category that properly links to a parent category.  See thread: http://www.magentocommerce.com/boards/viewthread/13146/

Also, I think the “category.remove” should’ve been “category.delete”, thats what I used and it worked.

This is all using 1.1 Stable.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lakikeanu
Jr. Member
 
Total Posts:  24
Joined:  2008-06-16
 

how to get
1.1-trunk SVN release

please explain....

 
Magento Community Magento Community
Magento Community
Magento Community
 
lakikeanu
Jr. Member
 
Total Posts:  24
Joined:  2008-06-16
 

i have the same problem “Suzy” and “JKwan13” had… i did all the corections.... but still the same…
it doesn’t run beyond
$client = new SoapClient("http://localhost/envoystore/index.php/api/soap/?wsdl");
line..
please help

 
Magento Community Magento Community
Magento Community
Magento Community
 
JKwan13
Member
 
Total Posts:  63
Joined:  2008-06-12
 

@lakikeanu - Try to use the latest 1.1 (Stable) release, which would be 1.1.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I keep getting this error:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn’t find <definitions> in ‘http://10.1.1.246/~rktest/api/?wsdl’ in /home/rktest/www/rkweb_soap.php:4 Stack trace: #0 /home/rktest/www/rkweb_soap.php(4): SoapClient->SoapClient(’http://10.1.1.2...’) #1 {main} thrown in /home/rktest/www/rkweb_soap.php on line 4

Also when I go into Web Services, go into roles, and create a role, I get the following error:

Warning: SimpleXMLElement::addAttribute() [function.SimpleXMLElement-addAttribute]: Attribute name and value are required in /home/rkweb/www/lib/Varien/Simplexml/Element.php on line 367
Trace:
#0 [internal function]: mageCoreErrorHandler(2, ‘SimpleXMLElemen...’, ‘/home/rkweb/www...’, 367, Array)
#1 /home/rkweb/www/lib/Varien/Simplexml/Element.php(367): SimpleXMLElement->addAttribute(’descr’, ‘’)
#2 /home/rkweb/www/lib/Varien/Simplexml/Element.php(387): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#3 /home/rkweb/www/lib/Varien/Simplexml/Element.php(387): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#4 /home/rkweb/www/lib/Varien/Simplexml/Element.php(387): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#5 /home/rkweb/www/lib/Varien/Simplexml/Element.php(387): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#6 /home/rkweb/www/lib/Varien/Simplexml/Element.php(326): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#7 /home/rkweb/www/lib/Varien/Simplexml/Config.php(586): Varien_Simplexml_Element->extend(Object(Mage_Core_Model_Config_Element), true)
#8 /home/rkweb/www/app/code/core/Mage/Api/Model/Config.php(72): Varien_Simplexml_Config->extend(Object(Mage_Core_Model_Config_Base), true)
#9 /home/rkweb/www/app/code/core/Mage/Api/Model/Config.php(43): Mage_Api_Model_Config->_construct()
#10 /home/rkweb/www/app/code/core/Mage/Core/Model/Config.php(715): Mage_Api_Model_Config->__construct(Array)
#11 /home/rkweb/www/app/Mage.php(287): Mage_Core_Model_Config->getModelInstance(’api/config’, Array)
#12 /home/rkweb/www/app/Mage.php(301): Mage::getModel(’api/config’, Array)
#13 /home/rkweb/www/app/code/core/Mage/Api/Model/Roles.php(64): Mage::getSingleton(’api/config’)
#14 /home/rkweb/www/app/code/core/Mage/Api/Model/Roles.php(46): Mage_Api_Model_Roles->_buildResourcesArray()
#15 /home/rkweb/www/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php(78): Mage_Api_Model_Roles->getResourcesList()
#16 /home/rkweb/www/app/code/core/Mage/Core/Controller/Varien/Action.php(343): Mage_Adminhtml_Api_RoleController->editRoleAction()
#17 /home/rkweb/www/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php(137): Mage_Core_Controller_Varien_Action->dispatch(’editrole’)
#18 /home/rkweb/www/app/code/core/Mage/Core/Controller/Varien/Front.php(168): Mage_Core_Controller_Varien_Router_Admin->match(Object(Mage_Core_Controller_Request_Http))
#19 /home/rkweb/www/app/Mage.php(420): Mage_Core_Controller_Varien_Front->dispatch()
#20 /home/rkweb/www/index.php(46): Mage::run()
#21 {main}

my file is as follows:

<?php
require_once('app/Mage.php');
Mage::app('default');
$client = new SoapClient('http://10.1.1.246/~rktest/index.php/api/?wsdl');

$session = $client->login('user', 'pass');

$client->endSession($session);
?>

the file I am using as my soap client is http://10.1.1.246/~rktest/rkweb_soap.php which is right in by base_url

I have tried using the follow in the new SoapClient(), but none work…
http://10.1.1.246/~rktest/api/?wsdl
or
http://10.1.1.246/~rktest/api/soap/?wsdl
or
http://10.1.1.246/~rktest/index.php/api/soap/?wsdl
or
http://10.1.1.246/~rktest/index.phpapi/?wsdl

I am using 1.1.3, I have 1.1.2… I can’t find ANYONE who is having this same problem, I can’t even find anyone who is having close to the same problem.

I have soap client and server enabled in php

I have tried to add extension=php_soap.so in php.ini, still didn’t work…

Could anyone guide me to fixing this problem? It would be much appreciated because I would really like to start using the Web Services Api, thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
JKwan13
Member
 
Total Posts:  63
Joined:  2008-06-12
 

I’m not quite sure what your problem is, but I will try to give you some pointers/suggestions:

You dont need:

require_once('app/Mage.php'); 
Mage::app('default');
unless you are actually programming within the Magento environment and directly linking your code with theirs.  Using the webservices API should remove those requirements.

You might want to reinstall 1.1.3 because creating a User/Role in Webservices in the Admin is neccessary to go foward.

Judging by the PHP error, it cant find the wsdl file from the SoapClient construter call.
What is your magento directory, is it “http://10.1.1.246/~rktest/”?  If it is, then all you should need is:
http://10.1.1.246/~rktest/api/soap/?wsdl
or
http://10.1.1.246/~rktest/index.php/api/soap/?wsdl

But make sure that is your magento directory, I’m not sure if some redirecting invovled might be the cause (which then I wouldnt know how to solve).

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I am leaving the office here in 15 minutes, but I will be working on this late into the night, so this might be a brief mesage.

Yes, that is my magento directory. I will install this on our server again, and I will install it on another webserver just to see if it works. I am getting the feeling its the web server and something to do with simplexml.

I did create a user, but not a role. Is a role necessary? I will continue this work this evening. I really appreciate your quick response, my company is really pushing me to get our site live on magento, but I just can’t seem to get this to work. Thanks so much, I will post my results this evening.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ChrisF
Member
 
Total Posts:  37
Joined:  2008-10-27
 

BlakeW, I’m having the same problem as what you posted http://www.magentocommerce.com/boards/viewthread/12367/P15/#t53906 - the issue with not being able to create a role. 

I’m assuming my SOAPclient call problem is related to that because I’m unable to set up a role.

Any resolution to this problem?

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

The resolution to my problem was to upgrade php to 5.2.6. There is a bug with simplexml and the older versions of php5. Let me know if this simple fix takes care of your problem like it did mine.

sorry for the duplication. I made a typo and didn’t stop the post quickly enough. “but"(typo) -> “bug”

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

The resolution to my problem was to upgrade php to 5.2.6. There is a bug with simplexml and the older versions of php5. Let me know if this simple fix takes care of your problem like it did mine.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ChrisF
Member
 
Total Posts:  37
Joined:  2008-10-27
 

Thanks for the reply blakew.  Yeah, I was afraid that I was going to have to upgrade PHP.  I had read about that problem before.  I’m on Debian Etch so that might be problematic.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 3