22

Okay, I think I need another pair of eyes to look over this. I'm making a simple php soapclient call to an echo web service on a remote server. I'm pretty sure I don't have any typos and that the function call is correct. However, I'm receiving a fatal error claiming the function isn't a valid method. Below is a var_dump of the web services types.

array(4) { [0]=> string(88) "struct EspException { string Code; string Audience; string Source; string Message; }" [1]=> string(71) "struct ArrayOfEspException { string Source; EspException Exception; }" [2]=> string(43) "struct EchoTestRequest { string ValueIn; }" [3]=> string(45) "struct EchoTestResponse { string ValueOut; }" }

Fatal error: Uncaught SoapFault exception: [Client] Function ("EchoTestRequest") is not a valid method for this service in /home/grafixst/public_html/cpaapp/echo_test.php:38 Stack trace: #0 /home/grafixst/public_html/cpaapp/echo_test.php(38): SoapClient->__call('EchoTestRequest', Array) #1 /home/grafixst/public_html/cpaapp/echo_test.php(38): SoapClientAuth->EchoTestRequest(Array) #2 {main} thrown in /home/grafixst/public_html/cpaapp/drew/echo_test.php on line 38

Here is the code I'm using to make the call:

require_once('SoapClientAuth.php');

ini_set("soap.wsdl_cache_enabled", "0");

#- Loading the WSDL document
$server = "https://wsonline.seisint.com/WsAccurint/EchoTest?ver_=1.65";
$wsdl = $server . "&wsdl";     

$client = new SoapClientAuth($wsdl,
                array(
                      'login' => $username,
                      'password' => $password
                     ));   

$types = $client->__getTypes();

var_dump($types);

echo "</br>";

$req = $client->EchoTestRequest(array('ValueIn' => 'echo'));

print $req->ValueOut;
echo "</br>";
miststudent2011
  • 279
  • 1
  • 4
  • 19
dsell002
  • 1,296
  • 2
  • 11
  • 24

2 Answers2

63

A simple request for the web service's available functions solved the problem.

$functions = $client->__getFunctions ();
var_dump ($functions);

EchoTestRequest was not a valid function call. The proper function call was EchoTest, which is illustrated by the functions variable dump.

array(1) { [0]=> string(54) "EchoTestResponse EchoTest(EchoTestRequest $parameters)" } 
dsell002
  • 1,296
  • 2
  • 11
  • 24
  • 2
    This saved my day! if a function is listed in WSDL but you cannot call it, check this answer, as it will reveal all functions available. – diynevala Jul 29 '15 at 10:25
  • After realizing that method was not in list I added "?v=1" to wsdl url and new wsdl was loaded with new method available. – wormhit Sep 01 '15 at 08:34
  • 1
    I ran into a similar problem and tried your answer, fixed the WSDL file. var_dump() would still give the same result. Turned out it was also caching the WSDL file. So your answer along with [this answer](http://stackoverflow.com/questions/303488/in-php-how-can-you-clear-a-wsdl-cache) solved the problem. Thanks. – Sanath Ballal Jun 24 '16 at 06:55
  • @dsell, suppose if i have more than one function for eg,. ` 0 => string 'AirRepriceRsp service(AirRepriceReq $parameters)' (length=48) 1 => string 'ScheduleSearchRsp service(ScheduleSearchReq $parameters)' (length=56) 2 => string 'LowFareSearchRsp service(LowFareSearchReq $parameters)' (length=54)` And i need to call a particular function, how i can do that. Thanks in advance. – Sawood Dec 15 '19 at 08:03
  • Please help me out with this : https://stackoverflow.com/questions/60314839/php-soap-client-call-to-wcf-service – user3479916 Feb 21 '20 at 05:26
26

I assume you're not typo and the method is actually available.

Try this

ini_set("soap.wsdl_cache_enabled", "0");

It's might be because of wsdl was cached.

ZenithS
  • 987
  • 8
  • 20
  • I am encountering the same problem and tries your solution, it doesn't work. have anything else in mind regarding this? – Saani Nov 17 '15 at 11:52
  • 9
    This solved my problem when switching PHP 5.6 with PHP 7 - maybe some caching problems when directly exchanging the versions. – iquito Mar 07 '16 at 19:01
  • 1
    Thank you a lot! I was trying accepted answer but called function was listed and I had no idea what's going on :) I'm also switching between PHP 5.6 and 7.0 just like @iquito – ElChupacabra Oct 11 '17 at 18:55