Reputation: 2140
I have a web application that involves calling a number of different XML/API webservices. The application has already been implemented in old school procedural code (by my predecessor) and I have managed to convince the IT director that it needs to be coded into a more robust framework. I've settled on CakePHP because it's the framework I am most familiar with.
I have Googled extensively for advice on how to consume an XML/API. One blog post did it in the controller, but I feel it belongs more in the model. Perhaps I could create a behaviour that handles the transfers and then code methods in the Model that will strip out the information I need from the returned XML?
Does anybody have some advice on this or a pointer?
Upvotes: 2
Views: 219
Reputation: 11420
I imagine you are using it to get database like data or config data, this is normally done in the model, though there is not restriction in where you do it. You could do the extracting and preparing of the data in the model and the logic in the controller. Something like loading the config parameters and putting them in variables and then using this variables in the controller.
Also you may use cakephp XML library to do all this. Since is a library you MAY do it either in controller or model.
Hope this helps you :)
Upvotes: 1