2012-07-13 150 views
0

我儘量讓肥皂服務用symfony 2,作爲一個結果,我有這樣的: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); 

}

有人有理念? THX

回答

1

由於documentationSoapFault建議,你需要提供兩個參數創建異常時:

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