ZF2 JSON server size issue: cannot set header

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ZF2 JSON server size issue: cannot set header

amit.dangwal
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hi All

I am new to Zend and putting up my best effort to learn and build an web applicaton using Zend framework2, Dojo and Zend Json server. I have written a html page using dojo components. My page first download completely(no json call at this point). I have added a onBlur function which makes call to Json server for response and parses the response to load country filterselect box. Dojo filterselect uses json rpc client which makes call to server and returns the data. If my data(record in DB) is upto 60 records then it works perfactly fine. But if that list is beyond 60 records(in may case 200+ records), zend server dumps an exception (as response it holds json data + exception which fails parsing) "Warning: Cannot modify header information - headers already sent by (output started at "

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


Please guide me on the issue as I am clueless as it works upto 60 rec and fails for more then that. Below is the exception I got. Is this a bug or any thing I missed. I validated it has nothing to do with Dojo as the direct call to service (using Restclient firefox addon) also it fails. If yes, then how can I log a ticket against it ? My work got stuck and I am not looking for workarounds for the problem as I have similar use case for other screens.

...sample data set below
{"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 />
( ! ) 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 62
Call Stack
#TimeMemoryFunctionLocation
10.0236644056{main}( )..\index.php:0
20.71789273664Zend\Mvc\Application->run( )..\index.php:12
31.811411844912Zend\EventManager\EventManager->trigger( )..\Application.php:303
41.811411845120Zend\EventManager\EventManager->triggerListeners( )..\EventManager.php:208
51.813811847840call_user_func
( )
..\EventManager.php:468
61.813811847872Zend\Mvc\View\SendResponseListener->sendResponse( )..\EventManager.php:468
71.813911847872Zend\Http\PhpEnvironment\Response->send( )..\SendResponseListener.php:71
81.813911847872Zend\Http\PhpEnvironment\Response->sendHeaders( )..\Response.php:100
91.814211848000header
( )
..\Response.php:62
"
Reply | Threaded
Open this post in threaded view
|

Re: ZF2 JSON server size issue: cannot set header

amit.dangwal
This post has NOT been accepted by the mailing list yet.
I strongly believe it is a defect and a fix has been created by me for this. Only Zend team will confirm about the issue and fix. Sadly as of now no one has looked into the issue.

More details are on below link: If you plan to use this fix then you have to make sure the fix is correct as I am not the right person to guarantee about the fix. For that conatct Zend framework team.
https://github.com/zendframework/zf2/issues/3225