Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP SOAP Procedure 'functionName' not present

Tags:

php

soap

symfony

I'm writing a SOAP application in Symfony and for all my request I'm getting an error Procedure 'getClusterName' not present.

Strange thing is that when I create a test SOAP application in pure PHP, it works fine, but the same code in Symfony returns an error.

Another strange thing is that when in the SOAP server code I list available service functions with $server->getFunctions(), it returns array of the service functions and getClusterName is in that array. So the function is known to the server, but it can't call it.

When writing the service in Symfony I followed this article and here is my code:

Client:

namespace Prj\SoapBundle\Controller;

class SoapController extends Controller
{
    public function indexAction()
    {
        $client = new \SoapClient('http://localhost/test.wsdl');
        $client->getClusterName();

Server:

namespace Prj\SoapBundle\Controller;

class SoapController extends Controller
{
    public function indexAction()
    {
    ini_set("soap.wsdl_cache_enabled", "0");
    $server = new \SoapServer($this->container->getParameter('wsdl'));
    $server->setClass('SoapBundle\HelloService');
    $server->handle();

Service:

namespace Prj\SoapBundle;

class HelloService
{
    public function getClusterName() 
    {
        return '<?xml version="1.0" encoding="utf-8"?><root>Hello!</root>';
    }
}

*.wsdl file seems to be correct because it binds the call with controller and works fine with vanilla PHP service.

On Internet this error usually explained by cached wsdl, but this is handled here in server code by setting soap.wsdl_cache_enabled parameter to zero.

like image 473
Minras Avatar asked Jul 26 '12 23:07

Minras


2 Answers

Even if setting soap.wsdl_cache_enabled = 0, try also emptying the /tmp folder.

like image 61
slash28cu Avatar answered Sep 24 '22 00:09

slash28cu


Clearing the tmp folder of wsdl- prefixed files worked for me. I also changed PHP's wsdl_cache_enabled option to 0 as suggested in my dev environment.

like image 4
SERVANT14 Avatar answered Sep 21 '22 00:09

SERVANT14