cannot have two operations in the same contract with the same name wcf
  • i am stuck in just my simple wcf program i am trying two method for fetch customer data one for fetch data on id base and second one will fetch data according to customer name but its throw error

    Activity 'Workflow1' validation failed: Cannot have two operations in the same contract with the same name, methods GetCustomerById and GetData in type WFServiceLibrary1.IWorkflow1 violate this rule. You can change the name of one of the operations by changing the method name or by using the Name property of OperationContractAttribute.


    my code is this

    [ServiceContract]
        public interface IWorkflow1
        {

            //[OperationContract]
            //string GetData(int value);

            // TODO: Add your service operations here

            [OperationContract(Name = "GetData")]
            string GetCustomerById(int value);
            [OperationContract(Name = "GetData")]
            string GetCustomerByName(string value);
        }
  • 1 Comment sorted by
  • Vote Up0Vote Down aftabaftab
    24.50 Karma Accepted Answer
    name attribute should be different try below code will work

    [ServiceContract]
    public interface IWorkflow1
    {

    [OperationContract]
    string GetData(int value);

    // TODO: Add your service operations here

    [OperationContract(Name = "GetCustomerById")]
    string GetCustomerById(int value);
    [OperationContract(Name = "GetCustomerByName")]
    string GetCustomerByName(string value);
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

    Optimum Creative