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 670213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:14:16+00:00 2026-05-14T00:14:16+00:00

I have a service with multiple contracts like so. [ServiceContract] public partial interface IBusinessFunctionDAO

  • 0

I have a service with multiple contracts like so.

[ServiceContract]
public partial interface IBusinessFunctionDAO {

    [OperationContract]
    BusinessFunction GetBusinessFunction(Int32 businessFunctionRefID);

    [OperationContract]
    IEnumerable<Project> GetProjects(Int32 businessFunctionRefID);
}

[ServiceContract]
public partial interface IBusinessUnitDAO {

    [OperationContract]
    BusinessUnit GetBusinessUnit(Int32 businessUnitRefID);

    [OperationContract]
    IEnumerable<Project> GetProjects(Int32 businessUnitRefID);
}

I then explicitly implemented each one of the interfaces like so.

public class TrackingTool : IBusinessFunctionDAO, IBusinessUnitDAO {

    BusinessFunction IBusinessFunctionDAO.GetBusinessFunction(Int32 businessFunctionRefID) {
      // implementation
    }
    IEnumerable<Project> IBusinessFunctionDAO.GetProjects(Int32 businessFunctionRefID) {
      // implementation
    }

    BusinessUnit IBusinessUnitDAO.GetBusinessUnit(Int32 businessUnitRefID) {
      // implementation
    }
    IEnumerable<Project> IBusinessUnitDAO.GetProjects(Int32 businessUnitRefID) {
      // implementation
    }
}

As you can see I have two GetProjects(int) methods, but each one is implemented explicitly so this compiles just fine and is perfectly valid. The problem arises when I actually start this as a service. It gives me an error staying that TrackingTool already contains a definition GetProject. While it is true, it is part of a different service contract. Does WCF not distinguish between service contracts when generating the method names ?
Is there a way to get it to distinguish between the service contracts ?

My App.Config looks like this

<service name="TrackingTool">
  <endpoint address="BusinessUnit" contract="IBusinessUnitDAO" />
  <endpoint address="BusinessFunction" contract="IBusinessFunctionDAO" />
</service>

Any help would be appreciated.

Thanks, Raul

  • 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-14T00:14:16+00:00Added an answer on May 14, 2026 at 12:14 am

    I think I found the reason for it. In the WSDL the function gets exposed as the following:

    <wsdl:message name="IBusinessUnitDAO_GetBusinessUnitProjects_InputMessage">
      <wsdl:part name="parameters" element="tns:GetBusinessUnitProjects" />
    </wsdl:message>
    <wsdl:message name="IBusinessFunctionDAO_GetBusinessFunctionProjects_InputMessage">
      <wsdl:part name="parameters" element="tns:GetBusinessFunctionProjects" />
    </wsdl:message>
    

    Then in the xsd that defines the tns: namespace we have the following:

    <xs:element name="GetBusinessUnitProjects">
      <xs:complexType>
        <xs:sequence>
          <xs:element minOccurs="0" name="businessUnitRefID" type="xs:int" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    
    <xs:element name="GetBusinessFunctionProjects">
      <xs:complexType>
        <xs:sequence>
          <xs:element minOccurs="0" name="businessFunctionRefID" type="xs:int" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    

    So the reason for the collision even though the the service is exposing two different contracts is because all of the wsdl part elements are in the same namespace. So when you create two function names that are identical you get duplicate elements with the same name which causes the problem. So the solution to the problem is to add a namespace attribute to each service contract. If we take our original service contract and modify it like so.

    [ServiceContract(Namespace="Tracking/BusinessFunction")]
    public partial interface IBusinessFunctionDAO {
    
        [OperationContract]
        BusinessFunction GetBusinessFunction(Int32 businessFunctionRefID);
    
        [OperationContract]
        IEnumerable<Project> GetProjects(Int32 businessFunctionRefID);
    }
    
    [ServiceContract(Namespace="Tracking/BusinessUnit")]
    public partial interface IBusinessUnitDAO {
    
        [OperationContract]
        BusinessUnit GetBusinessUnit(Int32 businessUnitRefID);
    
        [OperationContract]
        IEnumerable<Project> GetProjects(Int32 businessUnitRefID);
    }
    

    When we generate the WSDL we get a WSDL for each namespace we create. This namespace has each port identified with all its operations and elements. So inside each of our seperate WSDL’s we get the following:

    //File: Tracking.BusinessFunction.wsdl
    <wsdl:message name="IBusinessFunctionDAO_GetProjects_InputMessage">
      <wsdl:part name="parameters" element="tns:GetProjects" />
    </wsdl:message>
    
    //File: Tracking.BusinessUnit.wsdl
    <wsdl:message name="IBusinessUnitDAO_GetProjects_InputMessage">
      <wsdl:part name="parameters" element="tns:GetProjects" />
    </wsdl:message>
    

    as you can see they both have the same element name, but because they are in different namespaces the elements no longer conflict with each other. If we take a look at the xsd they now have the same elements defined but with different parameters:

    //File: Tracking.BusinessFunction.xsd
    <xs:element name="GetProjects">
      <xs:complexType>
        <xs:sequence>
          <xs:element minOccurs="0" name="businessFunctionRefID" type="xs:int" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    
    //File: Tracking.BusinessUnit.xsd
    <xs:element name="GetProjects">
      <xs:complexType>
        <xs:sequence>
          <xs:element minOccurs="0" name="businessUnitRefID" type="xs:int" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    

    So the answer to my original question is to make each service contract live in a separate namespace so you don’t have conflicting port elements. This also gives you the flexibility of having your contracts in separate WSDL’s which are easier to manage if you are distributing parts of them.

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

Sidebar

Ask A Question

Stats

  • Questions 458k
  • Answers 458k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you look in the XCode 'build results' window, and… May 15, 2026 at 10:59 pm
  • Editorial Team
    Editorial Team added an answer You could keep track of the block level with an… May 15, 2026 at 10:58 pm
  • Editorial Team
    Editorial Team added an answer The rule is negated, so it is executed if and… May 15, 2026 at 10:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.