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

Custom Module With Custom API
 
Ashley
Member
 
Total Posts:  51
Joined:  2008-07-23
 

I have created a custom module which stores a customer id and a boolean value in a table when somebody registers. This module works fine but I have the need to create an API for the module.

I have followed the Custom API guide in the wiki and have created the required files for the API. In the admin area the API functions show up in webservices/roles and I have a user which can access these functions.

Whenever I call the API functions for the module though I get an error indicating that a helper class cannot be found and I have no idea how to get it to work.

This is my api.xml file located in my modules etc folder

<config>
  <
api>
    <
resources>
      <
jkcustomer translate="title" module="JustKampers_Customer">
        <
title>Just Kampers Customer Resource</title>
        <
acl>jkcustomer</acl>
        <
methods>
          <list 
translate="title" module="JustKampers_Customer">
            <
title>Retrieve Just Kampers Customers</title>
            <
method>items</method>
            <
acl>jkcustomer/list</acl>
          </list>
          <
create translate="title" module="JustKampers_Customer">
            <
title>Create Just Kampers Customer</title>
            <
acl>jkcustomer/create</acl>
          </
create>
          <
info translate="title" module="JustKampers_Customer">
            <
title>Retrieve Just Kampers Customer Attributes</title>
            <
acl>jkcustomer/info</acl>
          </
info>
          <
update translate="title" module="JustKampers_Customer">
            <
title>Update Just Kampers Customer Attributes</title>
            <
acl>jkcustomer/update</acl>
          </
update>
          <
delete translate="title" module="JustKampers_Customer">
            <
title>Delete Just Kampers Customer</title>
            <
acl>jkcustomer/delete</acl>
          </
delete>
        </
methods>
        <
faults module="JustKampers_Customer">
          <
data_invalid>
            <
code>100</code>
            <
message>Invalid Customer Data</message>
          </
data_invalid>
          <
filters_invalid>
            <
code>101</code>
            <
message>Invalid filters specifiedDetails in error message.</message>
          </
filters_invalid>
          <
not_exists>
            <
code>102</code>
            <
message>Customer doesn't exist.</message>
          </not_exists>
          <not_deleted>
            <code>103</code>
            <message>Customer was not deleted. Details in error message.</message>
          </not_deleted>       
        </faults>
      </jkcustomer>
    </resources>
    <acl>
      <resources>
        <all>
          <jkcustomer translate="title" module="JustKampers_Customer">
            <title>Just Kampers Customer Resource</title>
            <list translate="title" module="JustKampers_Customer">
              <title>View All</title>
            </list>
            <create translate="title" module="JustKampers_Customer">
              <title>Create</title>
            </create>
            <info translate="title" module="JustKampers_Customer">
              <title>Get Info</title>
            </info>
            <update translate="title" module="JustKampers_Customer">
              <title>Update</title>
            </update>
            <delete translate="title" module="JustKampers_Customer">
              <title>Delete</title>
            </delete>
          </jkcustomer>
        </all>
      </resources>
    </acl>
  </api>
</config>

This is my config.xml file also located in my modules etc folder

<?xml version="1.0"?>
<config>
  <
modules>
    <
JustKampers_Customer>
      <
version>0.0.1</version>
      <
depends>
        <
Mage_Customer />
      </
depends>
    </
JustKampers_Customer>
  </
modules>
  <global>
    <
resources>
      <
jkcustomer_setup>
        <
setup>
          <
module>JustKampers_Customer</module>
          <class>
Mage_Core_Model_Resource_Setup</class>
        </
setup>
        <
connection>
          <use>
core_setup</use>
        </
connection>
      </
jkcustomer_setup>
      <
jkcustomer_write>
        <
connection>
          <use>
core_write</use>
        </
connection>
      </
jkcustomer_write>
      <
jkcustomer_read>
        <
connection>
          <use>
core_read</use>
        </
connection>
      </
jkcustomer_read>
    </
resources>
    <
models>
      <
jkcustomer>
        <class>
JustKampers_Customer_Model</class>
      </
jkcustomer>
    </
models>
    <
helpers>
      <
jkcustomer>
        <class>
JustKampers_Customer_Helper</class>
      </
jkcustomer>
    </
helpers>
  </global>
</
config>

I have also defined an Api.php file which has the functions corresponding to api.xml. This file is located in a folder called Customer which is also located in my modules directory.

I have created the following helper file in the module also

class JustKampers_Customer_Helper_Data extends Mage_Core_Helper_Abstract {
       
}

The problem comes when I call any of the modules API functions. I recieve;

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <
SOAP-ENV:Body>
        <
SOAP-ENV:Fault>
            <
faultcode>SOAP-ENV:Server</faultcode>
            <
faultstring>Class 'Mage_JustKampers_Customer_Helper_Data' not found</faultstring>
        </
SOAP-ENV:Fault>
    </
SOAP-ENV:Body>
</
SOAP-ENV:Envelope>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Ashley
Member
 
Total Posts:  51
Joined:  2008-07-23
 

Sorry for not keeping this thread updated I have been busy using the API!

I managed to solve this issue, there were typos I and I think I got the name of the class wrong. If anybody is having similair issues then I advise looking at the App/Code/Mage/ directory at the modules that come with an API interface already. I have since built about six custom modules each with there own API functionality in a similair fashion and all is working great. When I get some time i will write a tutorial on how to do this as there doesn’t seem to be much information especially for a beginner.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top