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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:51:16+00:00 2026-05-28T02:51:16+00:00

I’m trying to do self-hosting for a WCF callback service, based on this example

  • 0

I’m trying to do self-hosting for a WCF callback service, based on this example.

Here’s the hosting code:

service:

static void Main(string[] args)
    {
        using (ServiceHost host = new ServiceHost(typeof(Message), new Uri("http://localhost:8000/HelloWCF")))
        {
            // Set up a service endpoint [Contract, Binding, Address]
            host.AddServiceEndpoint(typeof(IMessage), new WSDualHttpBinding() { ClientBaseAddress = new Uri("http://locahost:8001/HelloWCF") }, "HelloWCF");

            // Enable metadata exchange
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior() {HttpGetEnabled =true };

            host.Description.Behaviors.Add(smb);
            host.Open();

            Console.WriteLine("Ready...");
            Console.ReadLine();
        }
    }

client:

app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsDualHttpBinding >
                <binding name="WSDualHttpBinding_IMessage" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" clientBaseAddress="http://locahost:8001/HelloWCF">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                    <security mode="Message">
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" />
                    </security>
                </binding>
            </wsDualHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8000/HelloWCF/HelloWCF" binding="wsDualHttpBinding"
                bindingConfiguration="WSDualHttpBinding_IMessage" contract="CallbackService.IMessage"
                name="WSDualHttpBinding_IMessage" >
                <identity>
                    <userPrincipalName value="badasscomputing\menkaur" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

c# code:

    [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
    class Sender : IMessageCallback, IDisposable
    {
        private MessageClient messageClient;

        public void Go()
        {
            InstanceContext context = new InstanceContext(this);
            messageClient = new MessageClient(context, "WSDualHttpBinding_IMessage");

            for (int i = 0; i < 5; i++)
            {
                string message = string.Format("message #{0}", i);
                Console.WriteLine(">>> Sending " + message);
                messageClient.AddMessage(message);
            }

        }

        public void OnMessageAdded(string message, DateTime timestamp)
        {
        }

        public void Dispose()
        {
            messageClient.Close();
        }
    }

    [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
    class Listener : IMessageCallback, IDisposable
    {
        private MessageClient messageClient;

        public void Open()
        {
            InstanceContext context = new InstanceContext(this);
            messageClient = new MessageClient(context, "WSDualHttpBinding_IMessage");

            messageClient.Subscribe();
        }

        public void OnMessageAdded(string message, DateTime timestamp)
        {
            Console.WriteLine("<<< Recieved {0} with a timestamp of {1}", message, timestamp);
        }

        public void Dispose()
        {
            messageClient.Unsubscribe();
            messageClient.Close();
        }
    }

    static void Main(string[] args)
    {
        Listener l = new Listener();
        l.Open();

        Sender s = new Sender();
        s.Go();
    }

the server starts alright.
when running the client, it crashes when trying to invoke any of the server functions with following exception:

EndpointNotFoundException:There was no endpoint listening at http://localhost:8000/HelloWCF/HelloWCF that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

The inner exception is:Unable to connect to a remote server.

This is not because of the firewall, as I successfully tested a similar app without a callback function

What could be the cause of this?

UPDATED

full source can be downloaded here: http://iathao.com/tmp/fullSource.zip

  • 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-28T02:51:16+00:00Added an answer on May 28, 2026 at 2:51 am

    With these small changes your code works fine on my machine.

    Client config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <wsDualHttpBinding>
                    <binding name="WSDualHttpBinding_IMessage" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                        <security mode="Message">
                            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                                algorithmSuite="Default" />
                        </security>
                    </binding>
                </wsDualHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:8000/HelloWCF" binding="wsDualHttpBinding"
                    bindingConfiguration="WSDualHttpBinding_IMessage" contract="CallbackService.IMessage"
                    name="WSDualHttpBinding_IMessage">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
            </client>
        </system.serviceModel>
    </configuration>
    

    Starter code

    namespace wcfStarter
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (ServiceHost host = new ServiceHost(typeof(Message), new Uri("http://localhost:8002/HelloWCF")))
                {
                    // Set up a service endpoint [Contract, Binding, Address]
                    host.AddServiceEndpoint(typeof(IMessage), new WSDualHttpBinding() { ClientBaseAddress = new Uri("http://locahost:8001") }, "HelloWCF");
    
                    // Enable metadata exchange
                    ServiceMetadataBehavior smb = new ServiceMetadataBehavior() {HttpGetEnabled =true };
    
                    host.Description.Behaviors.Add(smb);
                    host.Open();
    
                    Console.WriteLine("Ready...");
                    Console.ReadLine();
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.