0

我尝试用 symfony 2 做一个肥皂服务,结果我有这个:

     <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>

我的功能:

 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);

}

有人有想法吗?谢谢

4

1 回答 1

1

正如文档SoapFault建议的那样,您需要在创建异常时提供 2 个参数:

$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)
);
于 2012-07-13T11:28:12.510 回答