Archive

Posts Tagged ‘soapclient’

Soap Problems With Magento

November 19th, 2009 Comments off

We have had soap working with magento but has suddenly stopped working and causing errors in our script.

making this call twice seemed to fix the problem to the proxy and sessionID

<?
//$proxy = new SoapClient(‘http://www.xxx.co.uk/api/soap/?wsdl’, array(‘trace’=>1));
$proxy = new SoapClient(‘http://www.xxx.co.uk/api/soap/?wsdl’);
$sessionId = $proxy->login(‘xxx’, ‘xxx’);

$row_rsGetOrderInfo=$proxy->call($sessionId, ‘sales_order.info’, 100000324);
$trackitem_shipmethod=$row_rsGetOrderInfo[shipping_description];
echo “SHIP METHOD: $trackitem_shipmethod<BR><BR>”;

//try { $row_rsGetOrderInfo=$proxy->call($sessionId, ‘sales_order.info’, 100000319); } catch(SoapFault $soapFault){

//echo “<br><br>Fault: ” . var_dump($soapFault);
//echo “<br><br>Request :<br>”, htmlentities($proxy->__getLastRequest()), “<br>”;
//echo “<br><br>Response :<br>”, htmlentities($proxy->__getLastResponse()), “<br>”;

//}

//$proxy = new SoapClient(‘http://www.xxx.co.uk/api/soap/?wsdl’);
//$sessionId = $proxy->login(‘xxx’, ‘xxx’);

$row_rsGetOrderInfo=$proxy->call($sessionId, ‘sales_order.info’, 100000324);
$trackitem_shipmethod=$row_rsGetOrderInfo[shipping_description];
echo “SHIP METHOD: $trackitem_shipmethod<BR><BR>”;

?>

We then discovered last night that reinstantiate the SoapClient Object worked but today we have new / more problems with getting soap to work which previously worked:

Just worked out that I only need to reinstantiante the SoapClient object for it to work. I dont even need to log back in to the session.
i.e. I can do this first:
$proxy = new SoapClient(‘http://www.xxx.co.uk/api/soap/?wsdl’);
$sessionId = $proxy->login(‘xxx’, ‘xxx’);
Then execute a query:
try { $countries = $proxy->call($sessionId, ‘country.list’); } catch(Exception $e){ echo “<BR>ERROR Code : ” . $e->getCode() . “: ” . $e->getMessage(); }
Next time I just:
$proxy = new SoapClient(‘http://www.xxx.co.uk/api/soap/?wsdl’);
then execute another query.
And this works.
Are you there?
I’ve just recoded all that – run 5 test orders through successfully.
Noticed a small error with the order comments which I fixed.
Went to retest a single order and now getting a different error:
ERROR Code : 0: SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://www.xxx.co.uk/api/soap/?wsdl’

Bear