Question

I am just getting started with using Wcf Data Services to expose an entity framework database. I am quite familiar with WCF in general but not with data services.

I am trying to create a client without having to run the program and add a service reference.

This is because the database is not created, or complete, and there are other developers working on this.

I have looked at using the DataService<T>.AttachHost() method however this requires a IDataServiceHost which apparently DataServiceHost does not implement.

Does any one know a way to achieve this, or am I stuck with add service reference.

Thanks

EDIT

Just to explain a little more, as on reflection my question was poorly phrased.

Here is an example of the network setup

SQL SERVER | Firewall | APP SERVER | Firewall | CLIENTS

So there is a database on the SQL SERVER (MS-SQL)

The WcfDataService is running on the APP SERVER on port 1234. WcfDataService implemented by inheriting from DataService<MyContext> and hosting in a windows service

The clients need to connect to the DataService, using endpoint something like - htp://app-server:123465/

How can I create a class, preferably with an associated interface so I can unit test which would connect to the DataService and use its methods.

Thanks

Was it helpful?

Solution

It sounds like you are just asking how to create the client context. You can use DataServiceContext.

Example:

var serviceRoot = new Uri("http://app-server:123465/");
var context = new DataServiceContext(serviceRoot, DataServiceProtocolVersion.V3);

** There is more work beyond this... but this should get you started down the right path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top