0
我的web服務器已正確安裝SOAP(phpinfo具有SOAP客戶端/服務器 - 啓用)。PHP SOAP致命錯誤消息
我試圖創建一個SOAP請求到遠程Magento的商店,和我收到此錯誤信息:
[Mon Aug 29 20:13:59 2011] [error] [client 79.178.13.67] PHP Fatal error: Uncaught SoapFault exception: [0] Unable to load Soap extension on the server in /home/example/public_html/mag/index.php:3
Stack trace:
#0 [internal function]: SoapClient->__call('login', Array)
#1 /home/example/public_html/mag/index.php(3): SoapClient->login('user', 'pass')
#2 {main}\n thrown in /home/example/public_html/mag/index.php on line 3
代碼片段在這裏:
$client = new SoapClient('http://www.example.com/api/soap/?wsdl=1');
$session = $client->login('user','pass');
$attributeSets = $client->call($session,'product_attribute_set.list');
$set = current($attributeSets);
$sku = 'iphone-12345';
$imagePath="../image.jpg";
$newProductData = array(
'name' => 'iPhone',
'websites' => array(1),
'short_description' => 'short description',
'description' => 'description',
'price' => 150,
'status' => '1',
);
$newImage = array(
'file' => array(
'name' => 'file_name',
'content' => base64_encode(file_get_contents($imagePath)),
'mime' => 'image/jpeg'
),
'label' => 'Cool Image',
'position' => 0,
'types' => array('image','small_image','thumbnail'),
'exclude' => 0
);
$imageFilename = $client->call($sessionId, 'product_media.create', array($sku,$newImage));
$productId = $client->call($session,'product.create',array('simple', $set['set_id'],$sku,$newProductData));
echo $productId;
任何想法?
感謝,
檢查您的服務器安裝和配置。 http://www.magentocommerce.com/boards/viewthread/20556/ –
@Marek Sebera - 我從不同於我的Magento服務器的服務器運行腳本,這是否會影響任何內容?我知道SOAP在magento服務器上正確安裝,因爲當我在另一個服務器上加載wsdl url –
意味着另一個「VirtualHost」或整個服務器(整個Apache,httpd,nginx,...實例)時,我得到正確的XML響應?該錯誤表示加載SOAP擴展時存在問題,因此可能存在一些錯誤配置。 –