[英]Wcf Data Service Client
I am just getting started with using Wcf Data Services to expose an entity framework database. 我刚刚开始使用Wcf数据服务公开实体框架数据库。 I am quite familiar with WCF in general but not with data services.
总的来说,我对WCF非常熟悉,但对数据服务却并不熟悉。
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. 我已经看过使用
DataService<T>.AttachHost()
但是方法,这需要一个IDataServiceHost
这显然DataServiceHost
没有实现。
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 | SQL服务器| Firewall |
防火墙 | APP SERVER |
应用服务器 Firewall |
防火墙 | CLIENTS
CLIENTS
So there is a database on the SQL SERVER (MS-SQL) 因此,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 WcfDataService在端口1234上的APP服务器上运行。WcfDataService通过继承
DataService<MyContext>
并托管在Windows服务中来实现
The clients need to connect to the DataService, using endpoint something like - htp://app-server:123465/ 客户端需要使用类似htp:// app-server:123465 /的端点连接到DataService。
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. 如何创建一个类,最好是创建一个具有相关接口的类,以便可以对将连接到DataService并使用其方法的单元进行测试。
Thanks 谢谢
It sounds like you are just asking how to create the client context. 听起来您只是在问如何创建客户端上下文。 You can use DataServiceContext.
您可以使用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. **除此之外,还有更多工作要做……但这应该可以帮助您正确地开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.