Scenario
In this example, we will create a WCF IDataStore service that will be used by our client (Console Application) as a data layer. Instead of a direct connection to the database, our client will connect to a remote service and configure the WCF end point programmatically. This is usually helpful when:
- WCF specific customizations are required to provide custom bindings, endpoints, behavior, e.g. for a secured connection;
- Your WCF service is not hosted in IIS and thus no .svc files are used (e.g., when the WCF Class Library project is used).
Steps to implement
1. Create a remote data service and client as described in the How to connect to a remote data service instead of using a direct database connection example.
2. Create an EndPointHelper class which implements the GetDataStore static method as shown in the EndPointHelper.xx file. This method will be used to configure the WCF end point.
The key is in manual creation and custom configuration of the DataStoreClient and CachedDataStoreClient objects (you can see their default configurations by checking the source code of the CreateWCFWebServiceStore and CreateWCFTcpServiceStore methods of the DevExpress.Xpo.XpoDefault class).
3. Use the GetDataStore static method in the Main method as shown in the Program.xx file to configure end point and create a IDataStore.
Important notes
In XAF applications it is necessary to create a class that implements the IXpoDataStoreProvider interface and return the configured IDataStore. For additional information please refer to the How to use a custom ObjectSpaceProvider in XAF example that illustrates implementation of the IXpoDataStoreProvider interface.
See also:
Endpoints: Addresses, Bindings, and Contracts
How to connect to a remote data service from a Silverlight application
How to implement a distributed object layer service working via WCF
How to create a data caching service that helps improve performance in distributed applications
How to connect to a remote data service instead of using a direct database connection