Hi

I'm wondering what the correct method of serializing models for XML output 
should be?

After getting XML request routing working, via explicitly specifying xml in 
the Router::parseExtensions() call, I'm getting an error when doing a 
serialize on a paginated model.

The error is 

<response>
<script/>
<message>
DOMText::__construct() expects parameter 1 to be string, object given
</message>
<url>/authors.xml</url>
<code>500</code>
</response>

In my AuthorsController, the action is:

public function index() {
$authors = $this->paginate($this->Authors);
$this->set(array(
'authors' => $authors,
'_serialize' => array('authors')
));
}

In AppController, I have 

public $components = array('RequestHandler');

In routes.php I have

Router::mapResources('authors');
Router::parseExtensions(['xml']);

I have Template/Authors/index.ctp, but I'm expecting that to get used for 
the HTML request only.  The .xml extension should use the XmlView.

The URL usage is http://localhost/authors.xml

The error trace is:

2014-05-20 23:28:55 Error: [DOMException] DOMText::__construct() expects 
parameter 1 to be string, object given
Request URL: /authors.xml
Stack Trace:
#0 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\Utility\Xml.php(259):
 
DOMText->__construct(Object(Cake\ORM\ResultSet))
#1 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\Utility\Xml.php(322):
 
Cake\Utility\Xml::_fromArray(Object(DOMDocument), Object(DOMElement), 
Array, 'tags')
#2 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\Utility\Xml.php(283):
 
Cake\Utility\Xml::_createChild(Array)
#3 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\Utility\Xml.php(216):
 
Cake\Utility\Xml::_fromArray(Object(DOMDocument), Object(DOMDocument), 
Array, 'tags')
#4 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\View\XmlView.php(151):
 
Cake\Utility\Xml::fromArray(Array, Array)
#5 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\View\XmlView.php(115):
 
Cake\View\XmlView->_serialize(Array)
#6 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\Controller\Controller.php(620):
 
Cake\View\XmlView->render(NULL, NULL)
#7 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(143):
 
Cake\Controller\Controller->render()
#8 
C:\dev\projects\intalio-webservice\src\app\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(109):
 
Cake\Routing\Dispatcher->_invoke(Object(App\Controller\AuthorsController))
#9 C:\dev\projects\intalio-webservice\src\app\webroot\index.php(37): 
Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), 
Object(Cake\Network\Response))
#10 {main}

I guess because of the way that Models have changed, perhaps a ResultSet 
can not simply be serialized to XML that way that we might have done 
previously.

Is what I'm doing expected to work?

Regards
Reuben Helms

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to