HI,
in my
app/code/local/Mydons/Customapi/etc/config.xml magento folder path
<?xml version="1.0"?>
<config>
<modules>
<mydons_customapi>
<version>0.1.0</version>
</mydons_customapi>
</modules>
<global>
<models>
<customapi>
<class>Mydons_Customapi_Model</class>
</customapi>
</models>
<helpers>
<customapi>
<class>Mydons_Customapi_Helper</class>
</customapi>
</helpers>
</global>
</config>
-----------------------------------------------------------------------
in
app/code/local/Mydons/Customapi/etc/api.xml
<?xml version="1.0"?>
<config>
<modules>
<mydons_customapi>
<version>0.1.0</version>
</mydons_customapi>
</modules>
<global>
<models>
<customapi>
<class>Mydons_Customapi_Model</class>
</customapi>
</models>
<helpers>
<customapi>
<class>Mydons_Customapi_Helper</class>
</customapi>
</helpers>
</global>
</config>
----------------------------------------------------------------------------
Now we start creating our actual api model class Api.php in the directory. Our Api.php file is placed in the below directory
app/code/local/Mydons/Customapi/Model/Helloworld/Api.php.
Api.php contains a single method called hello which is specified in the api.xml file previously, the method accepts an argument and displays it along with its default message. customapi is the resourcename.
<?php
class Mydons_Customapi_Model_Helloworld_Api extends Mage_Api_Model_Resource_Abstract
{
public function hello($msg) {
return "My Custom HelloWorld API In Magento. Here is Your Message ". $msg ;
}
}
--------------------------------------------------------------------------------
app/etc/module/Mydons_Customapi.xml
<?xml version="1.0"?>
<config>
<modules>
<mydons_customapi>
<active>true</active>
<codepool>local</codepool>
</mydons_customapi>
</modules>
</config>
------------------------------------------------------
Creating a standalone file in magento root folder called helloworldapi.php and run as http://yourmagentosite.com/helloworldapi.php
<?php
// custom api soap client example
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();
$myhellomsg = "<b>Helloworld Mydons</b>";
try {
$soap = new SoapClient('http://yourmagentosite.com/api/?wsdl');
$sessionId = $soap->login('apiUser', 'apiKey');
//echo "Login ID : $sessionId";
$result = $soap->call($sessionId, 'customapi.hello',array($myhellomsg));
echo $result;
}
catch(Exception $e) {
echo $e->getMessage();
}
======================================
when i run the above helloworldapi.php
I get :
Function ("call") is not a valid method for this serviceERROR
please help!!!