开发者

Dynamically adding WCF Data Services Endpoints

开发者 https://www.devze.com 2023-02-05 17:51 出处:网络
I\'ve been researching oData and WCF DataServices and I think it would work great for my project. However, each of our clients have their own database.

I've been researching oData and WCF DataServices and I think it would work great for my project.

However, each of our clients have their own database.

So, is there a way to dynamically create a WCF endpoint that I could 开发者_高级运维point to a database. The schema for all the databases are identical.

For Example: Client1 needs DB1, they would use the URL: https://webservice.com/wcf/Client1 which would use DB1

Client2 needs DB2, they would use the URL: https://webservice.com/wcf/Client2 which would use DB2

Client3 needs DB3, they would use the URL: https://webservice.com/wcf/Client3 which would use DB3

Or I would need to be able to pass which database to connect to, but I don't how i would do that with WCF Data Services., I've done it with normal WCF services in the past though

They need to be dynamic because we are adding new clients all the time and we have an automated process for creating databases.

I know I could create a web service per database, but it would be much easier to maintain with 1 web service.


I found the answer.

Rather then creating multiple endpoints, I can just pass the Connection String from the webservice as a header.

Here's example code. It's really easy to implement and works great.

http://social.msdn.microsoft.com/Forums/en-NZ/adodotnetdataservices/thread/2eb0e7a8-10c5-4c6c-80b8-23cb39161345

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号