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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:25:01+00:00 2026-06-08T09:25:01+00:00

I have a WCF service that I am connecting in client application. I am

  • 0

I have a WCF service that I am connecting in client application. I am using following in configuration file.

<system.serviceModel>  
    <bindings>  
      <basicHttpBinding>  
        <binding name="MyNameSpace.TestService" closeTimeout="00:01:00" openTimeout="00:01:00"  
            receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"  
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"  
            maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"  
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"  
            useDefaultWebProxy="true">  
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384"  
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />  
          <security mode="None">  
            <transport clientCredentialType="None" proxyCredentialType="None"  
                realm="" />  
            <message clientCredentialType="UserName" algorithmSuite="Default" />  
          </security>  
        </binding>  
      </basicHttpBinding>  
    </bindings>  
    <client>  
      <endpoint address="http://localhost:9100/TestService" binding="basicHttpBinding"  
          bindingConfiguration="MyNameSpace.TestService" contract="TestService.IService" name="MyNameSpace.TestService" />  
    </client>  
</system.serviceModel>  

In the code, I am calling API on this service as follows,

TestServiceClient client = new TestServiceClient()
client.BlahBlah()

Now I want to defined endpoint porgramatically. How can that be done? I commented out section from config file as I was thinking I will have to put some code on TestServiceClient instance to add endpoint dynamically but then it throws following exception at the point where TestServiceClient is instantiated.

Could not find default endpoint element that references contract
‘TestService.IService’ in the ServiceModel client configuration
section. This might be because no configuration file was found for
your application, or because no endpoint element matching this
contract could be found in the client element.

How can I accomplish this? Also any point on code examples for adding endpoint programmatically will be appreciated.

  • 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-06-08T09:25:03+00:00Added an answer on June 8, 2026 at 9:25 am

    To create endpoints and bindings programmatically, you could do this on the service:

    ServiceHost _host = new ServiceHost(typeof(TestService), null);
    
    var _basicHttpBinding = new System.ServiceModel.basicHttpBinding();
                //Modify your bindings settings if you wish, for example timeout values
                _basicHttpBinding.OpenTimeout = new TimeSpan(4, 0, 0);
                _basicHttpBinding.CloseTimeout = new TimeSpan(4, 0, 0);
                _host.AddServiceEndpoint(_basicHttpBinding, "http://192.168.1.51/TestService.svc");
                _host.Open();
    

    You could also define multiple endpoints in your service config, and choose which one to connect to dynamically at run time.

    On the client program you would then do this:

    basicHttpBinding _binding = new basicHttpBinding();
    EndpointAddress _endpoint = new EndpointAddress(new Uri("http://192.168.1.51/TestService.svc"));
    
    TestServiceClient _client = new TestServiceClient(_binding, _endpoint);
    _client.BlahBlah();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service that needs to hosted using basicHttpBinding using SSL. So
I have a WCF application that at present is using XML based file storage
.NET 3.5, VS2008, WCF service using BasicHttpBinding I have a WCF service hosted in
I have a MSMQ application using WCF's netmsmqbinding. In the default configuration, and with
I have a WCF service that calls the following method in one of my
I have a Silverlight application that connects to a WCF service. Under the basic
I have a web application that is talking to a WCF service hosted within
I have a WCF service that accesses a SQL database to fetch data .
I have a WCF service that I need to call in a ASP.NET web
I have a WCF service that I can debug. I put a breakpoint in

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.