This is related question to my previous question but different one.
After searching a lot I’m not able to find the best solution for following WCF problem.
There is just one SVC file but multiple URLs to access it e.g. Organization Org1 will have URL http://CRMserver_name/Org1/XRMServices/2011/Organization.svc and Org2 will have http://CRMserver_name/Org2/XRMServices/2011/Organization.svc
I was trying this using URL Routing but problem is, it is creating REST services which we don’t want. We should be able to access these services just like normal WCF service. So if we add the URL http://CRMserver_name/Org1/XRMServices/2011/Organization.svc in WCF test client it should work.
CRM is doing it so there is a way but I’m not able to find it. Help me out!
Thanks,
Nilesh
After lot of research I’m going with safe way to achieve this. I’m going create separate WCF projects for each tenant and host them in separate IIS virtual dirs.
e.g. For Tenant1 –
http://localhost/ Tenant1/Service1.svcand for Tenant2 –http://localhost/Tenant2/Service1.svcNote that SVC name is same. Then I’m removing IService1.cs and Service1.svc.cs from Tenant2 and adding existing file as link from Tenant1. I need to do this for each new tenant and that’s why this is not pure solution. Now my solution explorer looks like following.
Here WcfService3 is for Tenant1 and WcfService1 is for Tenant2 (Sorry for this confusing names. I might fix it if someone need). So my WcfService3 properties look like following.
Now for both
http://localhost/ Tenant1/Service1.svcandhttp://localhost/ Tenant2/Service1.svcservice code is at single place which is in WcfServices3->Service1.svc.cs. Following code will create the database connection object for specific method call.I know this is not real solution for the problem (Multi-Tenant WCF services) but quick, easy and safe work around. Hope this helps someone. Also if you see any issues here or know better solution please let me know.
-Nilesh