0

I have created Api in my module, when I accessing through coding it is working fine, but in url (wsdl format) & web services list (Back-End) are not showing. If I give my custom Api to others, it should be in web services list because we will provide permissions for that. So, how can I configure the custom api in wsdl & web service list?

my code is:

local->Course->Mca->etc->api.xml

<?xml version="1.0"?>
<config>
    <api>
        <resources>
            <mca translate="title" module="mca">
                <model>mca/api</model>
                <title>MCA Student Resources</title>
                <methods>
                    <create translate="title" module="mca">
                    </create>
                </methods>
                <faults module="mca"><!-- module="mca" specifies the module which will be used for translation. -->
                    <data_invalid> <!-- if we get invalid input data for customers -->
                        <code>100</code >
                        <!-- we cannot know all the errors that can appear, their details can be found in error message for call -->
                        <message>Invalid Student data. Details in error message.</message>
                    </data_invalid>

                </faults>
            </mca>
        </resources>
    </api>
</config>

local->Course->Mca->Model->Api.php

<?php
class Course_Mca_Model_Api extends Mage_Api_Model_Resource_Abstract
{
    public function create($stuData)
    {
        return $stuData . ' My Custom Student Message';
    }

    public function info($stuId)
    {
    }

    public function items($filters)
    {
    }

    public function update($stuId, $stuData)
    {
    }

    public function delete($stuId)
    {
    }
}

thanks in advance.

1
  • Did you create an wsdl.xml in your Moules etc directory? Nov 14, 2013 at 12:22

2 Answers 2

1

To allow access to your api via the roles section on the of the "web services" section you will need to update your code to include the <acl> node in-between api and resources.

<?xml version="1.0"?>
<config>
    <api>
        <acl>
            <resources>
                <mca translate="title" module="mca">
                    <model>mca/api</model>
                    <title>MCA Student Resources</title>
                    <methods>
                        <create translate="title" module="mca">
                        </create>
                    </methods>
                    <faults module="mca"><!-- module="mca" specifies the module which will be used for translation. -->
                        <data_invalid> <!-- if we get invalid input data for customers -->
                            <code>100</code >
                            <!-- we cannot know all the errors that can appear, their details can be found in error message for call -->
                            <message>Invalid Student data. Details in error message.</message>
                        </data_invalid>
                    </faults>
                </mca>
            </resources>
        </acl>
    </api>
</config> 
2
  • I have updated my code, but it is not showing in web service list & wsdl(format). Oct 15, 2013 at 12:34
  • how do you get this list of web services? the above code will allow you to give this as a role under "SOAP/XML-RPC - Roles" Oct 15, 2013 at 13:13
0

Create a file calles app/code/local/Course/Mca/etc/wsdl.xml and compare its contents with one of those in core.

find app/code/core/Mage -iname 'wsdl.xml'

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.