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.