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:
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:
Troubleshooting1. If WCF throws the "Entity is too large" error, you can apply a standard solution from StackOverFlow: http://stackoverflow.com/questions/10122957/
2. If WCF throws the "The maximum string content length quota (8192) has been exceeded while reading XML data. " error, you can extend bindings in the following manner:
<bindings> <basicHttpBinding> <binding name="ServicesBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" > <readerQuotas maxDepth="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"/> </binding> </basicHttpBinding> </bindings>
Files to look at:• Customer.cs (VB: Customer.vb)
• Program.cs (VB: Program.vb)
• Service1.svc.cs (VB: Service1.svc.vb)
• Web.config (VB: Web.config)