Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6228463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:23:35+00:00 2026-05-24T09:23:35+00:00

This is related question to my previous question but different one. After searching a

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:23:37+00:00Added an answer on May 24, 2026 at 9:23 am

    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.svc and for Tenant2 – http://localhost/Tenant2/Service1.svc
    Note 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.

    SoluExp

    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.

    Project Prop

    Now for both http://localhost/ Tenant1/Service1.svc and http://localhost/ Tenant2/Service1.svc service code is at single place which is in WcfServices3->Service1.svc.cs. Following code will create the database connection object for specific method call.

        private static string dbServerName = "YourDBServerName";    
        private static SqlConnection dbConnection = createDBConnection();            
        private static SqlConnection createDBConnection()
        {
            Uri fullUri = OperationContext.Current.IncomingMessageHeaders.To;
            Uri baseAddress = new Uri(@"http://localhost");
            UriTemplate template = new UriTemplate(@"/{orgName}/Service1.svc");
    
            // retrieve the value of the artist segment
            UriTemplateMatch match = template.Match(baseAddress, fullUri);
            String orgName = match.BoundVariables["orgName"];        
    
            SqlConnection objConnection = new SqlConnection();
            objConnection.ConnectionString = createConnString(orgName);
    
            return objConnection;
        }
    
        private static string createConnString(string orgName)
        {
            return (String.Format("Data Source={0};Initial Catalog={1}_MSCRM;User Id=UserId1;Password=PasswordForUserId1;", dbServerName, orgName));
        }
    

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to my previous question , but a different one. I have
This is kind of related to my previous question, but not really. I have
This is related to my previous question but it is a different problem. I
This question is related to a previous question I asked, but it's a different.
Related to my previous question on this matter, where the file was not being
So this question is (somewhat distantly) related to this previous question: Best way to
This is somewhat related to my previous question but I've realised that I needed
This post relates to a previous that i posted but the question is different
This one is related to my previous question on the performance of Arrays and
This question is related to the previous one, when I click over an anchor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.