views:

32

answers:

1

Hi everybody! I'm new to php and have zero exprience with the cake-php. I created the php web services, which reads data from MySql and return to my iphone app. Previously I used the same code successfully in many app, But now I'm facing the problems in it. Because the web server on which I installed my web services is cake-php based. while my web services are written in simple php. I'm failing to get the data from them in my iphone app. Web services are working perfectly on localhost. but as Installed them on the server, I'm receiving binary data instead of xml file. I changed the encoding and content-type tag. Doing this web services returning the following fault code. error in msg parsing: Charset from HTTP Content-Type 'US-ASCII' does not match encoding from XML declaration 'utf-8'

So anyone can help me? Did I need to rewrite all of my web services in cake php or simple php web services can work?

by the way here is the code of one of my web service.

<?php
include('vp-config.php');
// Pull in the NuSOAP code
require_once('lib/nusoap.php');

define("PATH_DIR",str_replace("\\","/",dirname(__FILE__))."/");

$server = new soap_server;

$server->register('getAllNews');
function getAllNews($page) {

$conn = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
mysql_select_db(DB_NAME, $conn) or die(mysql_error());

 $q = "SELECT 
`website_contents`.`id`,
`website_contents` .`website_top_category_id`,
`website_contents` .`created`,
`website_contents` .`short_description`
FROM `website_contents` 
WHERE `website_contents`.`website_content_type_id` = 2 
 AND `website_contents` .`short_description` IS NOT NULL
ORDER BY id DESC LIMIT " . $page ." , 30";
$rs = mysql_query($q);

while($r = mysql_fetch_array($rs)){
       $items[] = array('id'=>$r['id'],                         
      'website_top_category_id'=>$r['website_top_category_id'],
      'created'=>$r['created'],
      'short_description'=>$r['short_description']
      );   
     }  
return $items;

}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$serve

r->service($HTTP_RAW_POST_DATA);

Thanks in advance.

A: 

CakePHP does a lot of content handling to ensure that you need to do a little work as possible. If you're just attempting to access some simple data, you might just leave it out of CakePHP and keep them as separate scripts. Creating them in CakePHP might be using a sledgehammer for hanging a picture frame (if you get my analogy).

Given your explanation in the comments, I would recommend importing them into CakePHP as libraries. You would be able to take your webservice code as a set of PHP files (or however you organized them) and they can be dropped into the appropriate folder in the app/ directory according to which version of Cake is being used. From there, they can included into the rest of CakePHP without you needing to know what your client is actually doing with his code.

Read up here for how your code would be imported. Keep in mind that significant changes have been made to this process between version 1.2 and 1.3 so note that in your reading below:

Hope this helps!

Michael
Thanks for the help. By them, I mean from web services. Problem is that I created these web services for my client. His web site is already running in cake php, And I have to install the web services on same server. In the begining he told me that web site is in php. But few days he explained that it is cakephp. I already created more then twenty web services. It's hard to re write them in cakePhp. Because I have zero knowledge of cakePhp. That's why I'm looking for solution. That is there a way to install the web services written in simple php on the cakePhp based web server? Thanks
Mas
Updated my answer in regard to your comment.
Michael
Thanks for the help. I have another idea. Is it possible I install another web server, with different path and port, on the server of my client. Then install the my php web services in the new web server. Which will of-course base on simple php?
Mas
That would also work, but that's probably the most expensive solution in regards to resources. You could always setup another virtual server without installing a whole new instance.
Michael