NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Simple problem with errors?


Joined: 14 Jun 2007
Posts: 67
Reply with quote
Hi All,

I'm just getting into using NuSoap and am having an issue with soap errors.

I've set up a soap server, and I have a simple function call that returns a string. I'm trying out the soap error stuff, and can't seem to pass errors from the soap server to the client.

Below is the code I'm using:
Code:

$NAMESPACE = 'http://localhost/soap.php';
$soap_server = new soap_server();
$soap_server->configureWSDL('awmsoap', $NAMESPACE, 'http://localhost/soap.php');

$soap_server->register(
   'getVersion',
   array(),
   array('return'=>'xsd:string'),
   $NAMESPACE
);

function getVersion() {
   GLOBAL $soap_server;
   //DebugBreak();
   $soap_server->setError("Error test");
   return 'test';
}

Calling the function via the soap client just returns the string 'test', not the soap error.

If I use $soap_server->wsdl->setError("Error test") then I get a serializing error.

Any light that can be shown on this would be appreciated. I'm basically wanting to throw a soap error if a user isn't authenticated, but I can't even get this simple test working!

Cameron
View user's profileFind all posts by CjungeSend private message


Joined: 14 Jun 2007
Posts: 67
Reply with quote
The client code I'm using:
Code:

$wsdl = "http://localhost/soap.php?wsdl";

// instantiate the SOAP client object
$soap = new soapclient($wsdl,"wsdl");
$proxy = $soap->getProxy();
$result = $proxy->getVersion();
if ($proxy ->fault) {
   echo 'Fault:<br>';
   var_dump($proxy );
}
if ($err = $soap->getError()) {
   echo 'Error:<br>';
   var_dump($err);
}
View user's profileFind all posts by CjungeSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Quote:
If I use $soap_server->wsdl->setError("Error test") then I get a serializing error.

but wsdl has very little to do with generating the errors, except the oen you got.

try returning soap_fault instance from the function:

Code:
if (_somethign_wrong_) {
  return new soap_fault('SERVER', '', 'parameter is wrong', $param);
} else {
  return new soapval('return', 'xsd:string', $returning_string);
}

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 14 Jun 2007
Posts: 67
Reply with quote
dmitri wrote:
Quote:
If I use $soap_server->wsdl->setError("Error test") then I get a serializing error.

but wsdl has very little to do with generating the errors, except the oen you got.

try returning soap_fault instance from the function:

Code:
if (_somethign_wrong_) {
  return new soap_fault('SERVER', '', 'parameter is wrong', $param);
} else {
  return new soapval('return', 'xsd:string', $returning_string);
}
Thanks Dmitri!

I'd already found soap_fault, so had managed to figure that part, but the addition of soapval will make the code a bit more obvious!

Thanks.
View user's profileFind all posts by CjungeSend private message
Simple problem with errors?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic