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

  • Home
  • SEARCH
  • 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 6563147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:47:43+00:00 2026-05-25T13:47:43+00:00

I am trying to create a WCF service, that has a webHttpBinding endpoint (for

  • 0

I am trying to create a WCF service, that has a webHttpBinding endpoint (for Java clients) and a netTcpBinding endpoint (for .NET clients).

With the netTcpBinding endpoint I would like to be able to use callbacks in order to be alerted to events, but when I try to configure this, WCF complains because the service also has the webHttpBinding endpoint, which doesn’t support callbacks.

Is there a way of having the callback utilised by one endpoint but not another?

  • 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-25T13:47:43+00:00Added an answer on May 25, 2026 at 1:47 pm

    No, the binding will validate that it can honor the contract; if the contract is a duplex contract (i.e., it specifies a CallbackContract) but the binding can’t do duplex, then it will throw during validation.

    What you can do is to have a base contract which is used by the webHttpBinding endpoint, and another contract (this time a duplex one), derived from the first, which is used by the netTcpBinding endpoint.

    The code below shows an example of such contract arrangement.

    public class StackOverflow_7341463
    {
        [ServiceContract]
        public interface ICalc
        {
            [OperationContract, WebGet]
            int Add(int x, int y);
            [OperationContract, WebGet]
            int Subtract(int x, int y);
            [OperationContract, WebGet]
            int Multiply(int x, int y);
            [OperationContract, WebGet]
            int Divide(int x, int y);
        }
        [ServiceContract(CallbackContract = typeof(ICalcNotifications))]
        public interface INotifyingCalc : ICalc
        {
            [OperationContract]
            void Connect();
            [OperationContract]
            void Disconnect();
        }
        [ServiceContract]
        public interface ICalcNotifications
        {
            [OperationContract(IsOneWay = true)]
            void OperationPerformed(string text);
        }
        public class Service : INotifyingCalc
        {
            static List<ICalcNotifications> clients = new List<ICalcNotifications>();
    
            #region ICalc Members
    
            public int Add(int x, int y)
            {
                this.NotifyOperation("Add", x, y);
                return x + y;
            }
    
            public int Subtract(int x, int y)
            {
                this.NotifyOperation("Subtract", x, y);
                return x - y;
            }
    
            public int Multiply(int x, int y)
            {
                this.NotifyOperation("Multiply", x, y);
                return x * y;
            }
    
            public int Divide(int x, int y)
            {
                this.NotifyOperation("Divide", x, y);
                return x / y;
            }
    
            #endregion
    
            #region INotifyingCalc Members
    
            public void Connect()
            {
                var callback = OperationContext.Current.GetCallbackChannel<ICalcNotifications>();
                clients.Add(callback);
            }
    
            public void Disconnect()
            {
                var callback = OperationContext.Current.GetCallbackChannel<ICalcNotifications>();
                clients.Remove(callback);
            }
    
            #endregion
    
            private void NotifyOperation(string operationName, int x, int y)
            {
                foreach (var client in clients)
                {
                    client.OperationPerformed(string.Format("{0}({1}, {2})", operationName, x, y));
                }
            }
        }
        class MyCallback : ICalcNotifications
        {
            public void OperationPerformed(string text)
            {
                Console.WriteLine("Operation performed: {0}", text);
            }
        }
        public static void Test()
        {
            string baseAddressTcp = "net.tcp://" + Environment.MachineName + ":8008/Service";
            string baseAddressHttp = "http://" + Environment.MachineName + ":8000/Service";
            ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddressHttp), new Uri(baseAddressTcp));
            host.AddServiceEndpoint(typeof(ICalc), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior());
            host.AddServiceEndpoint(typeof(INotifyingCalc), new NetTcpBinding(SecurityMode.None), "");
            host.Open();
            Console.WriteLine("Host opened");
    
            var factory = new DuplexChannelFactory<INotifyingCalc>(
                new InstanceContext(new MyCallback()),
                new NetTcpBinding(SecurityMode.None),
                new EndpointAddress(baseAddressTcp));
            var proxy = factory.CreateChannel();
            proxy.Connect();
            Console.WriteLine("Proxy connected");
    
            Console.WriteLine(new WebClient().DownloadString(baseAddressHttp + "/Add?x=4&y=7"));
            Console.WriteLine(new WebClient().DownloadString(baseAddressHttp + "/Multiply?x=44&y=57"));
            Console.WriteLine(new WebClient().DownloadString(baseAddressHttp + "/Divide?x=432&y=16"));
    
            proxy.Disconnect();
    
            Console.Write("Press ENTER to close the host");
            Console.ReadLine();
    
            ((IClientChannel)proxy).Close();
            factory.Close();
            host.Close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a WCF service that is accessible through both webHttpBinding
I am trying create a WCF service that leverages the WPF MediaPlayer on the
So I'm trying to create a C# WCF REST service that is called by
I am trying to create a WCF service that uses certificate authentication over SSL
I'm trying to create a client for a WCF service that I have hosted
I am trying to create a WCF service that will use message mode security
Trying to create an framework 4.0 WCF basicHttp service hosted by IIS (6) that
I am trying to create a WCF Streaming Service. I have two requirements that
Trying to create my first iPhone app that would play back audio. When I
I am trying to access a WCF web service, that is using two way

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.