Quantcast
Viewing all articles
Browse latest Browse all 7205

How to implement a distributed object layer service working via WCF

Scenario

In this example we will implement a distributed object layer service (IObjectLayer/ISerializableObjectLayer) working via WCF. A distributed services layer relies on lower layers, but hides the details of these layers from upper layers that contain the application and business logic layers. This arrangement allows the application developer to work at a higher level of abstraction layers.

Steps to implement:

1. Create a new Class Library project and add a Customer class via the DevExpress v1X.X ORM Persistent Object item template. You can see the source code of this class in the Customer.xx file.

2. Create a new WCF Service Application project and remove files with auto-generated interfaces for the service.

3. Add reference to the newly created class library.

4. Modify the Service class as shown in the Service.xx file to create a data provider and data layer.

5. Modify binding properties as shown in the example's web.config file. At this stage, the service part is ready to work and we need to implement a client to consume data from our data store service (for demonstration purposes, we will create a Console Application).

6. Add a Console Application into solution and add reference to the newly created class library.

7. Modify the Main method in the same manner as the Program.xx file to connect to our service using the web.config configuration.

8. The final step is to add the App.config file to our client application and modify it as shown in the example's App.config file.

If you run the client application, you will see the following output:
Image may be NSFW.
Clik here to view.

Important notes:
Please note that the port number in the connection string may be different. You can check it in the properties of the service project in the Solution Explorer:
Image may be NSFW.
Clik here to view.

 

See also:
Transferring Data via WCF Services
How to use XPO with a Web Service
How to serialize your XPO
How to connect to a remote data service instead of using a direct database connection


Viewing all articles
Browse latest Browse all 7205

Trending Articles