1

I read Alan Storm article (http://alanstorm.com/debugging_magento_api_method_calls) about magento core API. And now I just a bit confused, when I creating my custom API in magento, do I have to implement adapters and handlers? If no, is it any case when I will need to do this?

Also is there any good source where would be explained how to create custom API wsdl.xml and wsi.xml files ? or full tutorial of working custom API ?

I really would appreciate if anyone could share the resources or the knowledge about creating magento custom API :)

1 Answer 1

1

You don't need to create adapters and handlers. IN the article Alan wrote he explains how the handlers and adapters work. But they are already there. Of course if you want to add a new type of service you may need a handler but Magento already has SOAP and REST. What more do you want? :).

Here is a small example on how you can extend the existing API
Here is a big example on how you can add the files needed for the API in your custom module.

I can also recommend you this extension. It will build you a module with the SOAP API files included. It could be a good place to start learning how it works.
Build a module with it with the API included and one without the API then see what are the differences. that will tell you what files you need to create for the API.

9
  • I'm glad you respond. Thanks for responding about adapters and handlers. I actually copied a custom api from your given example link and tried to run it using v2 soap api but it gave me error: "Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'magentoloc/index.php/api/v2_soap?wsdl=1' : failed to load external entity ". Do you have an idea why this could happen?
    – intentarr
    Commented Feb 19, 2014 at 8:40
  • Most probably there is an error in your wsdl. Maybe I missed something in my post. You can use a wsdl validator tool like this one xmethods.net/ve2/Tools.po but there are many others that will tell you what the error is.
    – Marius
    Commented Feb 19, 2014 at 8:51
  • Ok, so I validated wsdl file here. It gave me some warnings: First warning is about Binding style (now it's rpc and they suggest to use document/literal). I also tried to change it to document/literal and then I got exception that neither of custom methods are found "There is no such type declared in the namespace 'urn:{{var wsdl.name}}'.". Other two warning was about naming conventions. Maybe you can give me a hint of these warnings and if it can be the root problem of why custom API not working??
    – intentarr
    Commented Feb 19, 2014 at 10:07
  • Sorry for the misunderstanding. You are not supposed to validate only the wsdl from your module. That won't work for sure. Magento generates a giant wsdl from all the wsdl files in all the modules. That should be validated. The one you get at the url api/v2_soap/?wsdl
    – Marius
    Commented Feb 19, 2014 at 10:10
  • Ok, so I validated whole magento wsdl link and I got an error that wsdl order is not correct but as I can't change it perhaps I should ignore this? And I get some warnings about "Maximum Number of Operations", "An endpoint URL should not exposes information about the used tools." and "All top-level complexType names should follow the same naming conventions to be consistent.". Do you have any advices according to this validation result?
    – intentarr
    Commented Feb 19, 2014 at 13:21

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.