8

When I try to access a function in wsdl with some data(using soap client in php) I am getting the following error.

Uncaught SoapFault exception: [Client] Function function_nameis not a valid method for this service

Any help?

Kevin
  • 53,822
  • 15
  • 101
  • 132
ravikiran reddy
  • 81
  • 1
  • 1
  • 2
  • 1
    Is that the actual error? Because if so I guess you have taken a template file from the service provider, and tried to make a call to a service function called `function_name` - which is unlikely to be the actual name of a function. You are supposed to replace `function_name` with the name of the function you are calling, it's just a placeholder to show you where the function name would go. The service provider likely provides documentation. I suggest you read it. Properly. – DaveRandom Dec 02 '11 at 10:26
  • Hi Dave thanks for response.that is not original error message.i replaced actual function name with 'function_name' – ravikiran reddy Dec 02 '11 at 10:45
  • Well even so, the error is telling you that the function name is not valid for that service you are trying to consume so re-check the docs and make sure the function name is valid, and if it is, contact the service provider. – DaveRandom Dec 02 '11 at 11:02
  • I have same issue when upgrade from PHP 5.6 to 7. In 7 method __getFunctions() says that function has but __call throws error. Problem was in wsdl cache. I changed soap.wsdl_cache_dir in php.ini of php7 and problem was solved – blackbass1988 Jan 11 '17 at 00:36
  • Hello guys, I have the same issue, changed to what @blackbass1988 ? – Paul Noris Oct 24 '17 at 19:22

5 Answers5

26

If you want to execute a function that SOAP can not find - it is possible that PHP cached the wsdl file.

Add this:

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

to disable the caching.

biphobe
  • 4,525
  • 3
  • 35
  • 46
2

Two possible solutions :

  1. try to see if the function really exists with the snippet of code there : PHP SoapClient request: not a valid method for this service
  2. Also, once you have displayed the list of available function calls, take care that if your WSDL is generated by a Java SOAP server, you might have several functions named "service" (or with the same name). Only the first one will be recognized and used by the PHP SOAP client. You need to manually rename all your in the WSDL !
Community
  • 1
  • 1
spiritoo
  • 451
  • 5
  • 15
1

I had this problem and finally decided to check my php error log.

In php.ini enable always_populate_raw_post_data = -1 and restart the server .

My PHP version is 5.6.8

Failed Scientist
  • 1,977
  • 3
  • 29
  • 48
0

Just add Parameters,Return type and Method of web service in comments at the top of the function. It will work. I tried its working.

/**
 * @param string the symbol of the stock
 * @return float the stock price
 * @soap
 */
public function getPrice($symbol)
{
    //...return stock price for $symbol
}
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
-1

In our situation this exception occurred when upgrading from PHP5.6 to PHP7. For us disabling the WSDL cache did also work.

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

Also see: http://lornajane.net/posts/2015/soapfault-when-switching-php-versions

Rvanlaak
  • 2,971
  • 20
  • 40