WordpressService.php
<?php
require_once("constants.php");
require_once("wso2/DataServices/DataService.php");
// database configuraitons
$config = array(
"db" => "mysql",
"username"=> DB_USER,
"password"=> DB_PASSWORD,
"dbname"=> DB_NAME,
"dbhost"=> DB_HOST);
// output format, plese check the API from http://wso2.org/wiki/display/wsfphp/API+for+Data+Services+Revised
$outputFormat = array("resultElement" => "Posts",
"rowElement" => "post",
"elements" => array( "title" => "post_title",
"content" => "post_content",
"date" => "post_date"));
// sql statment to execute, if you've not set explicitly WP_TABLE_PREFIX has the default value wp_
$sql="select post_title, post_content, post_date from ".WP_TABLE_PREFIX.
"posts where post_status='publish' ORDER BY ID DESC LIMIT 5";
// operations is consist of inputFormat (optional), outputFormat(required), sql(sql), input_mapping(optional)
$operations = array("getPosts"=>array("outputFormat"=>$outputFormat, "sql"=>$sql));
$my_data_service = new DataService(array("config"=>$config,"operations"=>$operations));
$my_data_service->reply();
?>