odataclient Consume OData Services

  1. Features
  2. Requirements
  3. Usage
  4. Howto
  5. Notes
  6. Resources

Integrates the OData SDK for PHP and simplifies consuming OData Services.

Features

  • delivers a DataProvider with Pagination and Sort support
  • Autogenerate service proxy classes 'on the fly'
  • Stores the metadata to extract dataset attributes

Requirements

  • Developed with Yii 1.1.8, should work with 1.1.6+
  • Installed PHP extensions: CURL and XSL
  • The OData PHP SDK is included. No need for extra download/install/configure

Usage

  • Extract the files into protected/extensions/odataclient
  • Ensure the directory protected/extensions/odataclient/services/classes is writeable The service proxy class files will be generated there.
  • Add the ODataController to the controllerMap in config/main.php
'controllerMap' => array(
     'odata'=>'ext.odataclient.controllers.ODataController',
  ),

Call 'index.php/odata' and see what happens.

The extensions is ready to retrieve data from the Northwind example and the OData demo

The proxy class files 'NorthwindEntities.php' and the metadata file 'NorthwindEntities.xml' ... should be created automatically. No need to create the class file on the commandline as in SDK.

Howto

Configure your OData services in the file 'odataclient/services/config.php'

return array(

  //The key is the 'serviceNameAlias' which is used as 'svc' parameter for the ODataController actions
  'northwind' => array(
  	 //the service proxy class name, autogenerated if not exists in the services/classes directory
  	 //if not is set, the key will be used
  	 'serviceName' => 'NorthwindEntities',
  	 //the OData Service Uri
  	 'serviceUri' => 'http://services.odata.org/Northwind/Northwind.svc',
  	 //optional: a subdirectory of services/classes where the classes are generated
  	 'serviceSubDir' => 'examples',
  	 //the options for the SDK on generating classes
  	 //used for authentication ... see SDK User Guide
  	 'options' => array(
  	 	               /*
  	                    '/u'=>'User',
  	                    '/p'=>'Password',
  	                    '/auth'=>'windows',
  	 	               */
		),

  ),

Take a look at the code/comments of the ODataController.

You can work with the SDK as you would do without this extension too (see actionSample1, actionSample2)

Take a look at the code/comments of EODataClient. For example to see how to extract values from the metadata file.

Notes

  • There is no Yii-like support for CRUD-Operations. There is no CModel behind the classes of the SDK. You have to study the samples of the SDK - me too ;-)

  • At the moment only reading is supported 'out of the box'

  • I have modified the framework/PHPDataSvcUtil.php of the SDK in a few lines (see comments there)

  • Please don't contact me about OData or SDK issues. This stuff is totally new for me.

Resources

0 0
3 followers
948 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Web Service
Tags: odata
Developed by: Joblo
Created on: Aug 8, 2011
Last updated: 12 years ago

Downloads

show all

Related Extensions