Search code examples
phpsoapsymfony1symfony-1.4nusoap

How to make NuSOAP works with Symfony 1.4?


I'm trying to make my webservice in symfony with NuSOAP. I also made a client for test purpose. I managed to make it work in my /web/ directory, but i can't access my symfony methods from there. So i created a new module in my frontend app, and i copied the content of my nuSOAP server file into indexSuccess.php. When i try to consume it, i get no error but also no results, and what's really strange is $proxy->response returning my homepage.

Here's my indexSuccess.php

require_once ("../lib/soap/nusoap.php");

$server = new soap_server();

$namespace = "Webservices";
$server->wsdl = new wsdl();
$server->wsdl->schemaTargetNamespace = $namespace;

$server->configureWSDL("Webservices", "Webservices");

function getDemandes($partnerCode)
{       

  $demandesArray = array(); 
  $demandeArray[] = array( 'id' => 5, 'poid_id' => 25, 'demande_type' => "Male" );
  $demandeArray[] = array( 'id' => 8,'poid_id' => 21, 'demande_type' => "Female");

  return $demandeArray;
}

$server->register(
    'getDemandes',
    array('partnerCode' => 'xsd:string'),
    array('getDemandesResponse'=>'tns:ArrayOfDemandesDatas'),
    $namespace,
    false,
    'rpc',
    'encoded',
    'Return requests'
    );
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$server->service($POST_DATA);
exit();

After further research I get the error Response not of type text/xml: text/html; charset=utf-8 whitch is not surprising because i have my default layout in the $request -> response, even if i disable it with $this->layout(false);


Solution

  • Maybe you should choose an option that is better integrated in Symfony. There is the ckWebservicePlugin for example. This plugin is tightly integrated in Symfony and would be a far better choice than using NuSOAP.