my problem has solved. I combine with post httpsocket http://book.cakephp.org/view/803/post
in web service project, i work according http://book.cakephp.org/view/477/The-Simple-Setup ex: 1. Make Recipes Controller <?php // file : app/controllers/recipes_controller.php class RecipesController extends AppController { var $data=array(); var $components=array('RequestHandler'); var $helpers=array('Html', 'Xml'); function add(){ if (isset($_POST[0])) $this->data['Recipe']=$_POST[0]; if ($this->data){ if ($this->Recipe->save($this->data)) { $data['result']=1; $data['message']='Recipe has been added'; } else { $data['result']=0; $data['message']='Error. please try again.'; } } $this->set(compact('data')); $this->RequestHandler->renderAs($this, 'xml'); } } ?> 2. make file app/views/layout/xml/default.ctp <?php // file : app/views/layout/xml/default.ctp echo $xml->header(); echo $content_for_layout; ?> 3. make file app/views/recipes/xml/add.ctp <container> <?php echo $xml->serialize($data);?> </container> DONE for web service project. then we need to make recipe project to consume web service. 1. Make Recipe model <?php // file : app/models/recipe.php class Recipe extends AppModel{ var $useTable=false; } ?> 2. make Recipes Controller <?php // file : app/controllers/recipes_controller.php class RecipesController extends AppController{ var $components=array('Session'); function beforeFilter(){ App::import('Core', 'HttpSocket'); App::import('Core', 'Xml'); } function add(){ if ($this->data){ $HttpSocket = new HttpSocket(); $data = $HttpSocket->post('http://localhost/recipeswebservice/ recipes/add', array($this->data['Recipe'])); $data = new Xml($data); $data = $data->toArray(); if ($data['Container']['StdClass']['result']) { $this->Session->setFlash($data['Container']['StdClass'] ['message']); $this->redirect('/'); die(); } else { $this->Session->setFlash($data['Container']['StdClass'] ['message']); } } } } ?> 3. Make view for add recipe <span><?php $session->flash(); ?></span><br/> <?php echo $form->create('Recipe', array('url'=>'/recipes/add'));?> <?php echo $form->input('recipe', array('type'=>'textarea'));?> <?php echo $form->end('Add');?> ALL DONE On Apr 6, 10:59 am, Rijal Asep Nugroho <[email protected]> wrote: > Dear all, > > I've tried to run step by step according to the manual about the REST > cakePHP (Chapter 4.10.1)http://book. cakephp.org/ view/477/ The-Simple- > Setup <http://book.cakephp.org/view/477/The-Simple-Setup>, had succeeded in > displaying the xml for the index and view actions. > > But I have problem to Add, Edit, Delete cause not finding an adequate > explanation about how to use POST, PUT, DELETE HTTP Method in the manual. > > please help me. thanks, > > regards, > Rijal Asep Nugroho Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
