luna dev
luna dev

Reputation: 43

symfony 2 + soap

I try to make a soap service with symfony 2, as a result I have this:

     <trace>at Symfony\Component\HttpKernel\Debug\ErrorHandler->handle('2', 'SoapFault::SoapFault() expects at least 2 parameters, 1 given', '/var/www/Symfony/src/Acme/TxBundle/Controller/DefaultController.php', '39', array('ref' => '333', 'stockinfos' => null))  in  line</trace>

my function:

 public function getInformationStockAction($ref)
{
      $stockinfos = $this->container->get('doctrine')->getRepository('TxBundle:LlxProduct')->findOneBy(array('ref'=>$ref))
  ;


     if (!$stockinfos)
    {
       throw new \SoapFault(sprintf('No warehouse found for the given productRef : "%s" ', $ref ));

         }

       return $this->container->get('besimple.soap.response')->setReturnValue($stockinfos);

}

someone have an idea? thx

Upvotes: 0

Views: 931

Answers (1)

richsage
richsage

Reputation: 27102

As the documentation for SoapFault suggests, you need to provide 2 parameters when creating the exception:

$faultCode = "yourCode"; // must be a string

throw new \SoapFault(
    $faultCodeHere, // This is the parameter you're missing :-)
    sprintf('No warehouse found for the given productRef : "%s" ', $ref)
);

Upvotes: 1

Related Questions