ZF2 JSON数据大小问题

时间:2012-12-13 18:55:31

标签: json rpc zend-framework2

我是Zend的新手,并尽最大努力学习和构建使用Zend framework2,Dojo和Zend Json服务器的Web应用程序。我使用dojo组件编写了一个html页面。我的页面首先完全下载(此时没有json调用)。我添加了一个onBlur函数,该函数调用Json服务器进行响应,并将响应解析为load country filterselect框。 Dojo filterselect使用json rpc客户端调用服务器并返回数据。如果我的数据(数据库中的记录)最多为60条记录,那么它的工作情况确实很好。但是如果该列表超过60条记录(可能情况下200多条记录),则zend服务器转储异常(作为响应它保存json数据+异常,解析失败)“警告:无法修改标头信息 - 已经发送的标头(输出已启动)在“

Json server details
    public function populatelistAction() {
    $class = "MO\Model\MOGuest";
    $server = new Server();
    $server->setClass($class);
    if ('GET' == $_SERVER['REQUEST_METHOD']) {
    $server->setTarget('populatelist')->setEnvelope(Smd::ENV_JSONRPC_2);
    $smd = $server->getServiceMap();
    // Set Dojo compatibility:
    $smd->setDojoCompatible(true);
    header('Content-Type: application/json');
    echo $smd;
    return $this->getResponse();
    } else {
    //$server->handle(); 
    }
    $server->handle();
    return $this->getResponse();
}

请指导我这个问题因为我无能为力,因为它可以达到60 rec并且失败了。以下是我得到的例外。这是一个错误或我错过的任何事情。我验证它与Dojo无关,因为直接调用服务(使用Restclient firefox插件)也失败了。

{"id":"208","catcode":"SR"},{"id":"209","catcode":"SJ"},{"id":"210","catcode":"SZ"},{"id":"211","catcode":"SE"},{"id":"212","catcode":"CH"},{"id":"213","catcode":"SY"},{"id":"214","catcode":"TW"},{"id":"215","catcode":"TJ"},{"id":"216","catcode":"TZ"},{"id":"217","catcode":"TH"},{"id":"218","catcode":"TL"},{"id":"219","catcode":"TG"},{"id":"220","catcode":"TK"},{"id":"221","catcode":"TO"},{"id":"222","catcode":"TT"},{"id":"223","catcode":"TN"},{"id":"224","catcode":"TR"},{"id":"225","catcode":"TM"},{"id":"226","catcode":"TC"},{"id":"227","catcode":"TV"},{"id":"228","catcode":"UG"},{"id":"229","catcode":"UA"},{"id":"230","catcode":"AE"},{"id":"231","catcode":"US"},{"id":"232","catcode":"UM"},{"id":"233","catcode":"UY"},{"id":"234","catcode":"UZ"},{"id":"235","catcode":"VU"},{"id":"236","catcode":"VE"},{"id":"237","catcode":"VN"},{"id":"238","catcode":"VG"},{"id":"239","catcode":"VI"},{"id":"240","catcode":"GB"},{"id":"241","catcode":"WF"},{"id":"242","catcode":"EH"},{"id":"243","catcode":"YE"},{"id":"244","catcode":"ZM"},{"id":"245","catcode":"ZW"}]],"id":"1"}<br />
<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: Cannot modify header information - headers already sent by (output started at C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\Json\Server\Server.php:182) in C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\Http\PhpEnvironment\Response.php on line <i>62</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0236</td><td bgcolor='#eeeeec' align='right'>644056</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\public\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.7178</td><td bgcolor='#eeeeec' align='right'>9273664</td><td bgcolor='#eeeeec'>Zend\Mvc\Application->run( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\public\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>12</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>3</td><td bgcolor='#eeeeec' align='center'>1.8114</td><td bgcolor='#eeeeec' align='right'>11844912</td><td bgcolor='#eeeeec'>Zend\EventManager\EventManager->trigger( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php' bgcolor='#eeeeec'>..\Application.php<b>:</b>303</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>4</td><td bgcolor='#eeeeec' align='center'>1.8114</td><td bgcolor='#eeeeec' align='right'>11845120</td><td bgcolor='#eeeeec'>Zend\EventManager\EventManager->triggerListeners( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php' bgcolor='#eeeeec'>..\EventManager.php<b>:</b>208</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>5</td><td bgcolor='#eeeeec' align='center'>1.8138</td><td bgcolor='#eeeeec' align='right'>11847840</td><td bgcolor='#eeeeec'><a href='http://www_php_net/call_user_func' target='_new'>call_user_func</a>
( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php' bgcolor='#eeeeec'>..\EventManager.php<b>:</b>468</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>6</td><td bgcolor='#eeeeec' align='center'>1.8138</td><td bgcolor='#eeeeec' align='right'>11847872</td><td bgcolor='#eeeeec'>Zend\Mvc\View\SendResponseListener->sendResponse( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php' bgcolor='#eeeeec'>..\EventManager.php<b>:</b>468</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>7</td><td bgcolor='#eeeeec' align='center'>1.8139</td><td bgcolor='#eeeeec' align='right'>11847872</td><td bgcolor='#eeeeec'>Zend\Http\PhpEnvironment\Response->send( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\Mvc\View\SendResponseListener.php' bgcolor='#eeeeec'>..\SendResponseListener.php<b>:</b>71</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>8</td><td bgcolor='#eeeeec' align='center'>1.8139</td><td bgcolor='#eeeeec' align='right'>11847872</td><td bgcolor='#eeeeec'>Zend\Http\PhpEnvironment\Response->sendHeaders( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\Http\PhpEnvironment\Response.php' bgcolor='#eeeeec'>..\Response.php<b>:</b>100</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>9</td><td bgcolor='#eeeeec' align='center'>1.8142</td><td bgcolor='#eeeeec' align='right'>11848000</td><td bgcolor='#eeeeec'><a href='http://www/php/net/header' target='_new'>header</a>
( )</td><td title='C:\Users\amsh\Documents\NetBeansProjects\myoffice\vendor\zendframework\zendframework\library\Zend\Http\PhpEnvironment\Response.php' bgcolor='#eeeeec'>..\Response.php<b>:</b>62</td></tr>
</table></font>"

1 个答案:

答案 0 :(得分:0)

我坚信这是一个缺陷,我已经为此创建了一个修复程序。只有Zend团队才能确认问题并解决问题。可悲的是,到目前为止还没有人研究过这个问题。

更多详细信息在下面的链接:如果您打算使用此修复程序,那么您必须确保修复是正确的,因为我不是保证修复的合适人选。对于那个conndct Zend框架团队。由于这是一个我只是Zend初学者的修复,所以修复必须由Zend团队认证或提供更好的解决方案。 https://github.com/zendframework/zf2/issues/3225