-1

I am trying to create custom api in magento

https://stackoverflow.com/questions/12172197/magento-api-publish-a-new-method-in-soap-v2/12258728#12258728?newreg=18f107c4fd89455ebd2b300992cf8fae

I am getting Below 2 errors

  1. While calling webservice

EXCEPTION=SoapFault exception: [4] Resource path is not callable. in D:\xampp\htdocs*****\CustomApiCaller.php:22 Stack trace: #0 D:\xampp\htdocs****\CustomApiCaller.php(22): SoapClient->__call('folderMyapimeth...', Array) #1 D:\xampp\htdocs*****\CustomApiCaller.php(22): SoapClient->folderMyapimethod('2ac263f18e06b89...', NULL) #2 {main}

  1. While browsing Edit role page form back end

Fatal error: Class 'Mage_Mymodule_Helper_Data' not found in D:\xampp\htdocs*****\app\Mage.php on line 547

Below are my files

Folder Structute

enter image description here

MyCompany_MyModule.xml

<?xml version="1.0"?>
<config>
    <modules>
        <MyCompany_MyModule>
            <active>true</active>
            <codePool>local</codePool>
        </MyCompany_MyModule>
    </modules>
</config>

Config.xml

<?xml version="1.0"?>
<config>
     <modules>
        <Mycompany_Mymodule>
          <version>1.0.0</version>
        </Mycompany_Mymodule>
    </modules>
    <global>
        <models>
            <MyModule>
                <class>MyCompany_MyModule_Model</class>
            </MyModule>
        </models>
        <!--<helpers>
        <MyModule>
            <class>MyCompany_MyModule_Helper</class>
        </MyModule>
        </helpers>-->
    </global>
</config>

Note - Here i tried both(without commenting helpers node also but not luck.

Api.xml

<?xml version="1.0"?>
<config>
     <modules>
        <Mymodule>
          <version>1.0.0</version>
        </Mymodule>
    </modules>
    <api>
        <resources>
            <mymodule_folder translate="title" module="mymodule">
                <title>mymodule</title>
                <model>mymodule/folder_api</model>
                <acl>mymodule/folder</acl>
                <methods>                    
                    <myapimethod translate="title" module="mymodule">
                        <title>myapimethod</title>
                        <acl>mymodule/folder/myapimethod</acl>
                    </myapimethod> 
                </methods>
            </mymodule_folder>
        </resources>
        <resources_alias>
            <folder>mymodule_folder</folder>
         </resources_alias>
        <v2>
            <resources_function_prefix>
                <folder>folder</folder>
            </resources_function_prefix>
        </v2>
        <acl>
            <resources>
                <mymodule translate="title" module="mymodule">
                    <title>mymodule</title>
                    <sort_order>1</sort_order>
                    <folder translate="title" module="mymodule">
                        <title>Folder</title>
                        <sort_order>2000</sort_order>                    
                         <myapimethod translate="title" module="mymodule">
                            <title>myapimethod</title>
                        </myapimethod>  
                    </folder>
             </mymodule>
            </resources>
        </acl>
    </api>
</config>

wsdl.xml

<?xml version="1.0" encoding="UTF-8"?>
    <definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
        name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
        <types>
            <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
                <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
            </schema>
        </types>
        <message name="folderMyapimethodRequest">
            <part name="sessionId" type="xsd:string"/>
            <part name="message" type="xsd:string" />
        </message>
        <message name="folderMyapimethodResponse">
            <part name="result" type="xsd:string" />
        </message>
        <portType name="{{var wsdl.handler}}PortType">
            <operation name="folderMyapimethod">
                <documentation>this is an example of api method...</documentation>
                <input message="typens:folderMyapimethodRequest" />
                <output message="typens:folderMyapimethodResponse" />
            </operation>
        </portType>
        <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
            <operation name="folderMyapimethod">
                <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
                <input>
                    <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </input>
                <output>
                    <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </output>
            </operation>
        </binding>
        <service name="{{var wsdl.name}}Service">
            <port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
                <soap:address location="{{var wsdl.url}}" />
            </port>
        </service>
    </definitions> 

wsi.xml

<wsdl:portType name="{{var wsdl.handler}}PortType">
    <wsdl:operation name="folderMyapimethod">
        <wsdl:documentation>Retrieve list of deal</wsdl:documentation>
        <wsdl:input message="typens:folderMyapimethodRequest" />
        <wsdl:output message="typens:folderMyapimethodResponse" />
    </wsdl:operation>

    </wsdl:portType>
<wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="folderMyapimethod">
        <soap:operation soapAction="" />
        <wsdl:input>
            <soap:body use="literal" />
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" />
        </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
<wsdl:service name="{{var wsdl.name}}Service">
    <wsdl:port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
        <soap:address location="{{var wsdl.url}}" />
    </wsdl:port>
</wsdl:service>

Note - I also tried bu not using wsi.xml file but not luck because compliance is set to no in back end.

Api.php ##

<?php
class Mycompany_Mymodule_Model_Folder_Api extends Mage_Api_Model_Resource_Abstract
{        
        public function myapimethod( $message)
        {
            return "This is the message: ".$message;
        }
}

V2.php ##

<?php
class Mycompany_Mymodule_Model_Folder_Api_V2 extends Mycompany_Mymodule_Model_Folder_Api
{   

}

Note - Also tried including helper folder and Data.php file and referring in config.xml but still not luck.

Can someone please check what I am missing here....

Let me know if any more information is needed.

Thanks Siddharth

2 Answers 2

3

I can not help you with the "resource path is not callable" issue, but I would assume that it has something to do with you developing in a local XAMPP environment.

For the problem with the helper that is not found:

You have to un-comment the helper-classification in your config.xml and rename the "Helperasdasd"-folter to "Helper"; in there must lay a file called Data.php with the class declaration:

<?php

class MyCompany_Mymodule_Helper_Data extends Mage_Core_Helper_Data {}

This is enough for the contents of this file.

Also, in the api.xml file, everywhere you use module="mymodule", update this to exactly the name of the helper-config-path in the config.xml; you are on Windows I guess, and thus it may not be case sensitive. on every other system, it is. Additionally, I don't believe Windows is officially supported my Magento.

0

Finally I am able to resolve issue....After much head scratching and comparing my files back and forth with core api files

First as you said, I have updated all config files with exactly same name(considering case senstivity) of files/folders.

Still i was getting same error, not sure how but Then I realized that a closing global tab .. was missing in config.xml file :( :(

And bang it worked liked charm....Thanks

Let me know if anybody needs updated files.

[Edit] - Missed to mention - also renamed helper folder and reffered it in config.xml, this actually i tried before but didn't worked then...may be it worked because of putting names exactly same.

Thanks Siddharth

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.