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

problem to see my own webservice methods
 
Matthieu MARY
Member
 
Total Posts:  33
Joined:  2008-08-28
France
 

hello,

I have try to add my own webservice module with the help of the wiki article
http://www.magentocommerce.com/wiki/doc/webservices-api/custom-api

so I have made the following package:

/etc/api.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <
api>
        <
acl>
            <
resources>
                <
all>
                </
all>
            </
resources>
        </
acl>
        <
resources>
            <
import translate="title" module="import">
                <
title>import Resource</title>
                <
methods>
                    <list 
translate="title" module="import">
                        <
title>Retrive imports</title>
                    </list>
                    <
create translate="title" module="import">
                        <
title>Create import</title>
                    </
create>
                    <
info translate="title" module="import">
                        <
title>Retrieve import data</title>
                    </
info>
                    <
update translate="title" module="import">
                        <
title>Update import data</title>
                    </
update>
                    <
delete>
                        <
title>Delete import</title>
                    </
delete>
                </
methods>
                <
faults module="import">
                    <
data_invalid><!-- if we get invalid input data for imports -->
                        <
code>100</code>
                        <!-- 
we cannot know all the errors that can appeartheir details can be found in error message for call -->
                        <
message>Invalid import dataDetails in error message.</message>
                    </
data_invalid>
                    <
filters_invalid>
                        <
code>101</code>
                        <
message>Invalid filters specifiedDetails in error
                            message
.</message>
                    </
filters_invalid>
                    <
not_exists>
                        <
code>102</code>
                        <
message>import doesn't exist.</message>
                    </not_exists>
                    <not_deleted>
                        <code>103</code>
                        <message>
                            import was not deleted. Details in error
                            message.
                        </message>
                    </not_deleted>
                </faults>
            </import>
        </resources>
        <acl>
            <resources>
                <all></all>
            </resources>
        </acl>
    </api>
</config>

etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <!-- 
turn on our modulerequired for install support -->
    <
modules>
        <
Sqli_Import>
            <
version>0.1.0</version>
            <
depends>
                <
Mage_Api />
            </
depends>
        </
Sqli_Import>
    </
modules>
    <global>
        <!-- 
turn on database connections -->
        <
resources>
            <!-- 
setup is needed for automatic installation -->
            <
import_setup>
                <use>
default_setup</use>
            </
import_setup>
            <
import_write>
                <use>
default_write</use>
            </
import_write>
            <
import_read>
                <use>
default_read</use>
            </
import_read>
        </
resources>
    </global>
</
config>

Helper/Data.php

<?php
/**
 * default helper for the sqli import module
 * @package Sqli
 * @subpackage Import
 */
class Sqli_Import_Helper_Data extends Mage_Core_Model_Abstract
{}

Model/Api.php

<?php
/**
 * $Id$
 * @package Sqli
 * @subpackage Import
 */
/**
 * api model for the import module
 * @see http://www.magentocommerce.com/wiki/doc/webservices-api/custom-api
 * @package Sqli
 * @subpackage Import
 */
class Sqli_Import_Model_Api extends Mage_Api_Model_Resource_Abstract
{
    
/**
     */
    
public function create ($customerData)
    
{
    }
    
/**
     */
    
public function info ($customerId)
    
{

    }
    
/**
     */
    
public function items ($filters)
    
{
    }
    
/**
     */
    
public function update ($customerId$customerData)
    
{

    }
    
/**
     */
    
public function delete ($customerId)
    
{
    }
}
|/code]
Model
/Server/Adapter/Import.php

[code]
<?php
/**
 * required adapter for the import webservice
 * @see http://www.magentocommerce.com/wiki/doc/webservices-api/custom-api
 * @package Sqli
 * @subpackage Import
 */
class Sqli_Import_Model_Server_Adapter_Import extends Varien_Object implements Mage_Api_Model_Server_Adapter_Interface
{
    
/**
     */
    
protected $_xmlRpc null;
    
/**
     */
    
public function setHandler ($handler)
    
{
        $this
->setData('handler'$handler);
        return 
$this;
    
}
    
/**
     */
    
public function getHandler ()
    
{
        
return $this->getData('handler');
    
}
    
/**
     */
    
public function setController (Mage_Api_Controller_Action $controller)
    
{
        $this
->setData('controller'$controller);
        return 
$this;
    
}
    
/**
     */
    
public function getController ()
    
{
        
return $this->getData('controller');
    
}
    
/**
     */
    
public function run ()
    
{
        $this
->_xmlRpc = new Zend_XmlRpc_Server();
        
$this->_xmlRpc->setClass($this->getHandler());
        
$this->getController()->getResponse()->setHeader('Content-Type''text/xml')->setBody($this->_xmlRpc->handle());
        return 
$this;
    
}
    
/**
     * Dispatch webservice fault
     *
     * @param int $code
     * @param string $message
     */
    
public function fault ($code$message)
    
{
        
throw new Zend_XmlRpc_Server_Exception($message$code);
    
}
// Class Mage_Api_Model_Server_Adapter_Customxmlrpc End
?>
But when I ask http://myserver/api/?wsdl, I can’t see my own methods.
I have made something wrong or did I call the wrong url?
Please help
Best regards
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top