dizzy1 Posted March 5, 2010 Share Posted March 5, 2010 The "soap call function" seems not be called, can someone tell me where if thier is such a thing as a "soap call function" and where i can find it, to include it. stockclient.php <?php require_once('nusoap/lib/nusoap.php'); $c = new soapclient('http://www.eximiusdesigns.co.uk/soap/stockserver.php?wsdl'); $stockprice = $c->call('getStockQuote', array('symbol' => 'ABC')); echo "The stock price for 'ABC' is $stockprice. <br> <br>"; ?> Quite simple and straight forward how ever i get this error when i run stockclient.php : Fatal error: Uncaught SoapFault exception: [Client] Function ("call") is not a valid method for this service in C:\xampp\htdocs\soap\stockclient.php:8 Stack trace: #0 [internal function]: SoapClient->__call('call', Array) #1 C:\xampp\htdocs\soap\stockclient.php(: SoapClient->call('getStockQuote', Array) #2 {main} thrown in C:\xampp\htdocs\soap\stockclient.php on line 8 Quote Link to comment Share on other sites More sharing options...
freakstyle Posted March 5, 2010 Share Posted March 5, 2010 The error you are getting is happening because the method you are trying to use in the service does not exist. I attempted to look at the wsdl but found no valid service exists at that url. So either the service is not up or the method you are calling 'getStockQuote', is not a valid method for that service. Good luck. Quote Link to comment Share on other sites More sharing options...
dizzy1 Posted March 5, 2010 Author Share Posted March 5, 2010 Cheers i had fixed it, it was the wrong method, I needed to have $c = new nusoap_client("http://www.eximiusdesigns.co.uk/soap/stockserver.php?wsdl", true); instead of $c = new soapclient('http://www.eximiusdesigns.co.uk/soap/stockserver.php?wsdl'); Quote Link to comment Share on other sites More sharing options...
stuart475898 Posted March 18, 2010 Share Posted March 18, 2010 Thought I would just use this thread rather than start a new one as its along the same lines. Is it possible to have PHP check to see if a method exists for a webservice. i.e. $test = new SoapClient("file.wsdl"); if(method_exists($test, "someMethod")) { echo "GOOD"; } else { echo "BAD"; } I had a go with the method_exists function, but it seems to return false if it exists or not. Thanks for the help Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted March 18, 2010 Share Posted March 18, 2010 Since your error included an exception message, you must be on PHP5. Therefore you can use exceptions to determine if the method exists or not. <?php try { $exists = true; $c->call('doesThisMethodExist', array('symbol' => 'ABC')); } catch( Exception $ex ) { $exists = strpos( $ex->getMessage(), 'Function ("doesThisMethodExist") is not a valid method for this service' ) === false; } ?> I whipped that up on the fly so while the concept should be sound, the code may not be right. That method is a little out of the way; this might be easier: http://www.php.net/manual/en/soapclient.getfunctions.php Or poke around in the SOAP documentation: http://www.php.net/manual/en/book.soap.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.