Jump to content

PHP soap


dizzy1

Recommended Posts

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(8): SoapClient->call('getStockQuote', Array) #2 {main} thrown in C:\xampp\htdocs\soap\stockclient.php on line 8

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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');

 

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.