Joined: 09 Dec 2008 |
Posts: 1 |
|
|
|
Posted: Mon Dec 08, 2008 5:50 pm |
|
|
|
|
|
I have a server written using PHP5's native SoapServer:
ini_set("soap.wsdl_cache_enabled","0");
ini_set("soap.wsdl_cache_ttl","0");
$soap = new SoapServer("http://api.danielprocter.com/wsdl",array("soap_version" => SOAP_1_2));
$soap->setClass('Services');
$soap->handle();
I have a PHP5 client that connects beautifully to it using the following code (calling the simple add function):
$client = new SoapClient("http://api.danielprocter.com/wsdl");
$response = $client->Add(array("Key"=>"MYKEY","ItemA"=>"3","ItemB"=>"4"));
print_r($response);
It all works well until I install the latest nusoap on a server else where in order to consume the service from a remote server using nusoap as it is running PHP 4.XXX
When I call the following code (Nusoap has been required and included properly):
$client = new nusoap_client("http://api.danielprocter.com/wsdl",true);
$response = $client->call("Add",array("Key"=>"MYKEY","ItemA"=>"3","ItemB"=>"4"));
print_r($response );
I get the following output:
Array ( [faultcode] => SOAP-ENV:Server [faultstring] => Procedure 'Add' not present )
Anyone shed any light on this? It's driving me nuts. I never seem to have any luck trying to work with nusoap !
{EDIT}
This is what my Services class looks like:
class Services
{
private function Authenticate($key)
{
return ($key=="MYKEY");
}
function StoreAmazonCheckout($params)
{
$result = new SimpleResult();
$authenticated = $this->Authenticate((string)$params->Key);
if($authenticated)
{
$items = unserialize((string)$params->SerializedItems);
foreach($items as $item)
{
# DO SOME PROCESSING
}
# successful insert
$result->SetResult(1);
}
# response is -1 cause it didnt authenticate
else $result->SetResult(-1);
return array("StoreAmazonCheckoutResult"=>$result);
}
# in development
function AmazonSearch($params)
{
global $Amazon;
$keywords = (string)$params->Keywords;
$index = (string)$params->Index;
$page = (string)$params->Page;
if(!$page) $page = 1;
$data = $Amazon->ItemSearch($keywords,$index,$page);
}
function Add($params)
{
$result = new SimpleResult();
$a = intval($params->ItemA);
$b = intval($params->ItemB);
$result->SetResult(($a+$b));
return array("AddResult"=>$result);
}
}
class SimpleResult
{
var $Result = "0";
function SetResult($v) { $this->Result = $v; }
}
|
|