我已经关注了该插件的tutorial并且它有效,但我刚刚尝试返回一个字符串(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”。