Giter Club home page Giter Club logo

xpo_how-to-connect-to-a-remote-data-service-instead-of-using-a-direct-database-connection-e4930's Introduction

Files to look at:

How to connect to a remote data service instead of using a direct database connection

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 the direct connection to the database, our client will connect to a remote service, which is way more secure and thus important in many enterprise scenarios as database connection settings are not exposed to the client.


Steps to implement

1. Create a new WCF Service Application project and add references to the DevExpress.Data and DevExpress.Xpo assemblies and remove files with auto-generated interfaces for the service.

2. Modify the service class as shown in the Service1 file. This service initializes a connection provider and stores it in the static DataStore property, which is then used by the base DataStoreService class.

3. Change some 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).

4. Add the Console Application into the existing solution.

5. Add a new code file for a Customer class using the DevExpress v1X.X ORM Persistent Object item template. See a code of Customer class in the ConsoleApplication\Customer code file.

6. Pass the address of our service into the GetDataLayer method of the XpoDefault class. For this, modify the Main method of the Console Application as shown in the ConsoleApplication\Program code file. 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:


As a result, we will see the following output:

Important notes
If you are using an XAF client, then in the simplest case, you can just set the XafApplication.ConnectionString to the address of your data store service (http://localhost:55777/Service1.svc). Refer to the Connect an XAF Application to a Database Provider help article for more details.

Troubleshooting
1. If WCF throws the "Request Entity 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 as per http://stackoverflow.com/questions/6600057/the-maximum-string-content-length-quota-8192-has-been-exceeded-while-reading-x:

<bindings>
      <basicHttpBinding>
        <binding name="ServicesBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" >
          <readerQuotas maxDepth="2147483647"
            maxArrayLength="2147483647"
            maxStringContentLength="2147483647"/>
        </binding>
      </basicHttpBinding>
</bindings>

 

See Also:
How to use XPO with a Web Service
Transferring Data via WCF Services
How to connect to a remote data service from a Silverlight application

How to create a data caching service that helps improve performance in distributed applications

How to implement a distributed object layer service working via WCF

How to connect to remote data store and configure WCF end point programmatically

 


Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

xpo_how-to-connect-to-a-remote-data-service-instead-of-using-a-direct-database-connection-e4930's People

Contributors

devexpressexamplebot avatar uriahas avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.