Forum Moderators: coopster

Message Too Old, No Replies

Unable to initialize a SOAP client

SOAP script works on local PC, doesn't work on remote host

         

ndaru

3:28 am on Dec 9, 2006 (gmt 0)

10+ Year Member



Hi,

I'm trying to connect to Amazon Web Service using SOAP.

This script works successfully on my local PC, using PHP 4.3.3, but doesn't work at all on my remote host, using PHP 4.3.9.

PEAR SOAP is installed on both local PC and remote host.


<?php
// include SOAP class
include("SOAP/Client.php");

print_r("this to include SOAP/Client.php");

// initialize SOAP client
$soapclient = new SOAP_Client("http://webservices.amazon.com/onca/soap?Service=AWSECommerceService");

print_r("this to create new SOAP_Client object");

// set data for SOAP request
$params = array('SubscriptionId' => '105Y5APC8J1S4A1XATG2', 'ItemId' => 'B000K1CS5Y');

print_r("this to pass the params");

// call an ECS method
$result = $soapclient->call("ItemLookup", $params);

print_r("this to call to Amazon SOAP server");

// check for errors
if (PEAR::isError($result)) {
die("Something went wrong...");
}
// else print ECS return values
print_r($result);
?>

On remote host, it only shows:

this to include SOAP/Client.php

Which means, the script fails on:

$soapclient = new SOAP_Client("http://webservices.amazon.com/onca/soap?Service=AWSECommerceService");

Also, my host's support told me that my package is using PHP5, while phpinfo() shows me that my package is using PHP 4.3.9.

Which one is true? I did try to modify the code to use PHP5's native SOAP functions, like the support guy's suggestion. But it still doesn't work.


<?php

$client = new SoapClient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl");

print_r("this to create new SOAPClient object");

$params = array(
'keyword' => 'paul reinheimer',
'page' => 1,
'mode' => 'books',
'tag' => 'preinheimerco-20',
'type' => 'lite',
'devtag' => '105Y5APC8J1S4A1XATG2'
);

$result = $client->KeywordSearchRequest($params);
foreach ($result->Details AS $product)
{
echo '<a href="' . $product->Url . '">' .
$product->ProductName . "</a><br>\n";
echo '<img src="' . $product->ImageUrlSmall .
'" border="0" alt="book cover"><br>' . "\n";
}

?>

The script shows nothing, which means it fails on:

$client = new SoapClient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl");

Please help,

Thanks.

eelixduppy

6:42 am on Dec 9, 2006 (gmt 0)



Have you checked your error logs? My guess is that your php configuration is different than the one on their server. Check the logs for errors first. They will should you the way :)