我已经按照该插件的教程进行操作,它可以工作,但是我只是尝试返回一个字符串(foobar)而不是乘法运算的结果:
/**
* An action multiplying two numbers.
*
* @WSMethod(webservice='MathApi')
*
* @param double $a Factor A
* @param double $b Factor B
*
* @return string The result //this is the first change
*/
public function executeMultiply($request)
{
$factorA = $request->getParameter('a');
$factorB = $request->getParameter('b');
if(is_numeric($factorA) && is_numeric($factorB))
{
$this->result = 'foobar'; //this is the second and last change
return sfView::SUCCESS;
}
else
{
return sfView::ERROR;
}
}
当我运行网络服务时,我得到了这个:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://sf1prueba.local/">
<SOAP-ENV:Body>
<ns1:factura_multiplyResponse>
<result>0</result>
</ns1:factura_multiplyResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
如您所见,它以结果“0”的形式返回,而我期望的是“foobar”。