How can I create a Custom SOAP/XML-RPC V1 & V2 API in Magento?
Magento – How to Create Custom SOAP/XML-RPC API
apimagento-1.6php-5.4
Related Solutions
It's a kind of error which shows that Magento doesn't find the method of your API. So you have an issue how you define this method in the api.xml. By the way I saw several potential issues. See below
- You don't need to create again the public function
create
in your classCourse_Mca_Model_Mca_Api_V2
because you extendCourse_Mca_Model_Mca_Api
and this one has the same method. - Your method
Course_Mca_Model_Mca_Api::create
expects a string as a parameter and a string as a returned value, in your WSDL definition, you define a kind of array (which is anyway badly defined). For your test purpose and to allow you a step by step coding, do:
Replace in wsdl.xml
<message name="mcaMcaCreateRequest">
<part name="sessionId" type="xsd:string" />
<part name="data" type="typens:mcaMcaCreateEntity" />
</message>
<message name="mcaMcaCreateResponse">
<part name="result" type="xsd:int"/>
</message>
With
<message name="mcaMcaCreateRequest">
<part name="sessionId" type="xsd:string" />
<part name="data" type="xsd:string" />
</message>
<message name="mcaMcaCreateResponse">
<part name="result" type="xsd:string"/>
</message>
- You will have to update also the wsi.xml file like you did for the wsdl.xml file
- Into api.xml, you have maybe some issue too, do the following:
Replace
<resources_alias>
<mca>mca_mca</mca>
</resources_alias>
<v2>
<resources_function_prefix>
<mca>mcamca</mca>
</resources_function_prefix>
</v2>
with
<resources_alias>
<mca>mca_mca</mca>
</resources_alias>
<v2>
<resources_function_prefix>
<mca>mcaMca</mca>
</resources_function_prefix>
</v2>
Then in your test code, use the V2 Soap Version
$proxy = new SoapClient('http://localhost/ics/index.php/api/v2_soap?wsdl');
$sessionId = $proxy->login('magento', 'magento@123');
$result = $proxy->mcaMcaCreate($sessionId, 'my text test');
print_r($result);
Did you try to specify them?
customer.info looks like to have a third attribute which allows you to pass an array of requested attributes. I have no clue about SOAP, so I might be wrong, but if the attributes are not returned, \Mage_Customer_Model_Api_Resource::_isAllowedAttribute
might filter them.
Good luck.
Best Answer
You can read this. It explains a lot but it's mostly for API V1.
To show you how you can create an API I think it's better to offer an example.
Let's say you have a module named
Easylife_Portfolio
with an entity namedProject
.For this entity you can set the name, description and status.
Here are the files you need in addition to the rest of the files (controllers, models, blocks..).
app/code/local/Easylife/Portfolio/etc/api.xml
- the api declaration file.app/code/local/Easylife/Portfolio/etc/wsdl.xml
- wsdl part for V2app/code/local/Easylife/Portfolio/etc/wsi.xml
- it's similar towsdl.xml
but it's used for WS-I complienceThe example did not fit in one answer. See the rest of the files here
Note: These files were created using the Ultimate Module Creator. I've just added some comments in the xml files.