6

I'm trying to use Magento's SOAP V2 api. The URI path for the API is http://www.example.com/api/v2_soap. When I'm making my request I'm using http://www.example.com/api/v2_soap?wsdl. The request correctly shows the wsdl xml file but if I try to run this code from the command line I get an error that says 'looks like we got no XML document':

        try{
                $client = new SoapClient('http://www.example.com/api/v2_soap?wsdl');
                $session = $client->login('username', 'apiKey');

                var_dump($session);
    }catch(Exception $e){
        var_dump($e->getMessage());
        var_dump($client->__getLastRequest());
        var_dump($client->__getLastResponse());
    }

I believe I've narrowed this down to the soap:address in the wsdl file. The location value is set to the index.php file rather than the api path or the api.php file.

<service name="MagentoService">
  <port name="Mage_Api_Model_Server_V2_HandlerPort" binding="typens:Mage_Api_Model_Server_V2_HandlerBinding">
  <soap:address location="http://www.example.com/index.php/?type=v2_soap"/>
 </port>
</service>

I can't quite find where this url is generated or how to change it to the correct value.

In addition to using http://www.example.com/api/v2_soap?wsdl I've also tried using http://www.example.com/index.php/api/v2_soap?wsdl as I've seen mentioned in other questions, but that doesn't have any effect on the address location value.

Any help to point me in the right direction would be greatly appreciated.

  • The error message you are getting is thrown by PHP, not Magento. – Lord Skeletor Jan 26 '15 at 18:43
  • Did you solve this? I think that isn't the correct way to connect to SOAP v2 – Natalie Apr 15 '15 at 21:48
  • The URL is generated in: /app/code/core/Mage/Api/Model/Wsdl/Config/Base.php around line 57 as reporter here: magento.stackexchange.com/questions/74753/… – WaPoNe Oct 26 '16 at 15:33
1

Hope you have created users and assigned role, below article will guide to do so, I have also included sample php code which works well

http://siddharthvaghasia.com/2014/12/10/enable-magento-soap-api-from-backend-to-enable-client-application-to-connect-with-magento-store/

Now to be specific about your questions, do check your .htaccess file redirection rules, it might be possible some of redirection might be sending request to different url than you are intentded to do.

  • The page no longer exists. – jstuardo Apr 12 at 22:51
  • Edited link in answer...please check now.. – Siddharth Vaghasia Apr 14 at 4:49

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