Multi Tenant Service APIs for business objects and business logic

We have an application in which we want to identify a large number of database objects and some business logic. Each object will require the ability to read, add, and update. we do not currently expect permission to delete.

The software that we create is used in a wide range of business, so many of them work with the services of the Bureau, and some of our clients use this approach to create separate databases for financial reasons.

We want to be able to minimize the number of endpoints that need to be maintained. Currently, there are only 3 tables that will be displayed as WCF interfaces, each of which has 6 attached methods. this is manageable, but if there are 50 databases in the job that suddenly become 150 endpoints. worse, if we have 50 tables, which become 2500 endpoints.

Does anyone have a suggestion on how we could design the system, we still have a simple entity model Job.add (var1) or iList jobs = Job.GetSelected ("sql type read").

without all of these endpoints

+7
wcf
source share
5 answers

WCF Data Services allows you to provide your data in a RESTful way using the prototype Open Data (OData). This was formally called ADO.Net Data Services, and before that Astoria. Any IQueryable collection can be exhibited. The method shown in most examples is to use the Entity Framework, however there are examples showing use with NHibernate and other data access technologies. OData is a self-describing API based on Atom-Pub with some custom extensions. With a minimal amount of code, you can provide a complete database in a well-defined format. This is the easy part.

To implement multi-user mode, you can create request interceptors in the WCF data services application to implement this logic. The number of interceptors and the complexity of the code you write will depend on your security model and requirements. Looking at something like T4 or CodeSmith patterns to generate hook methods based on your database schema may be a way to prevent a lot of repetitive manual coding.

The link provided by me contains a lot of information and tutorials on WCF data services and will provide a good place to start understanding if it suits your needs. I was looking for WCF data services for a similar problem (multi-user) and I would love to hear how you always implement your solution.

+1
source share

It seems that you can pass an "identifier" to each request and take this into account. This would mean that every entry in your "Job" table should have a reference to the owner id, but that should not be a big problem.

Just make sure that every request checks for an "identifier" and you should be fine.

0
source share

If I understand your question correctly, I think you need unique endpoints, but you can have one service behavior that refers to endpoints.

Create a default endpoint:

<behaviors> <serviceBehaviors> <behavior name="MyService.DefaultBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> 

Set the default binding:

 <bindings> <wsHttpBinding> <binding name="DefaultBinding"> <security mode="None"> <transport clientCredentialType="None"/> </security> </binding> </wsHttpBinding> </bindings> 

Do all service references indicate default behavior and binding:

 <service behaviorConfiguration="MyService.DefaultBehavior" name="MyService.Customer"> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="DefaultBinding" contract="MyService.ICustomer"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> 

Each time you add a service, its a simple configuration record.

0
source share

Providing high-rise buildings, without Bazillion endpoints

One way is to use a REST-style WCF service that can use username / passwords to distinguish who you work with, and therefore be able to choose which database to connect to. WCF provides you with a UriTemplate that allows you to map part of the URL to a parameter in your web methods:

You can add other Uri templates for more tasks, for example:

Who uses my service?

In order for clients to specify a username and password, you can map this to a specific database. And using the UriTemplate from / {tableName} / {operation} / {params ...} , you can use the code in your web service to execute database procedures based on the table, operation and parameters.

Flow around

Your web configuration does not need a significant change. The next series of web articles is a great place to learn about REST-style web services that I think are suitable for what you need: http://www.robbagby.com/rest/rest-in-wcf -blog-series-index /

0
source share

With Apache, you can use a fairly simple set of URL rewriting rules to map an arbitrary set of DB table tables and their corresponding endpoints to a single endpoint with a parameter.

For example, to map $ ROOT / table_name / column_name to $ ROOT / index.php? tn = table_name & cn = column_name, you can add a rule like this to $ ROOT / .htaccess:

 RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/?$ index.php?tn=$1&cn=$2 [QSA,L] 

Then you only need to support $ ROOT / index.php (which, of course, can generate the appropriate HTTP status codes for non-existent tables and / or columns).

0
source share

All Articles