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

The Archive Base Latest Questions

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

I have a remote wcf service, I connect it by WSHttpBinding. If I use

  • 0

I have a remote wcf service, I connect it by WSHttpBinding. If I use the empty service constructor which mean it will take all the configurations from the app.config , everything is ok, (I mean MyService s = new MyService()).
Now I want to configure the wcf programmatically . it’s simple till I arrive to the authentication issue , it was so hard to do that . Here is the app.config which I use , you can see there my security configurations .

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="SecuredEndPoint" 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"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="true" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" negotiateServiceCredential="true"
                        algorithmSuite="Default" />
                </security>
            </binding>               
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://MyWcfService.svc"
            binding="wsHttpBinding" bindingConfiguration="SecuredEndPoint"
            contract="ServiceReference1.IMyService" name="SecuredEndPoint">
            <identity>
                <certificate encodedValue="*******************************************************************" />
            </identity>
        </endpoint>            
    </client>
</system.serviceModel>
  • 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-28T03:16:55+00:00Added an answer on May 28, 2026 at 3:16 am

    I have done this, you might have to modify your code for security mode you have in config

    public virtual ChannelFactory<T> Proxy<T>(string address) {
          //Validate Address
          if (string.IsNullOrEmpty(address)) throw new ArgumentNullException("Address can not be null or empty.");
          //Address
          EndpointAddress endpointAddress = new EndpointAddress(address);
    
          //Binding
          WSHttpBinding wsHttpBinding = new WSHttpBinding(SecurityMode.None, false);
          wsHttpBinding.OpenTimeout = wsHttpBinding.CloseTimeout = new TimeSpan(0, 1, 0);
          wsHttpBinding.ReceiveTimeout = wsHttpBinding.SendTimeout = new TimeSpan(0, 10, 0);
          wsHttpBinding.MaxReceivedMessageSize = wsHttpBinding.MaxBufferPoolSize = 2147483647;
          wsHttpBinding.BypassProxyOnLocal = wsHttpBinding.AllowCookies = wsHttpBinding.TransactionFlow = false;
          wsHttpBinding.MessageEncoding = WSMessageEncoding.Text;
          wsHttpBinding.TextEncoding = Encoding.UTF8;
          wsHttpBinding.UseDefaultWebProxy = true;
          wsHttpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
          wsHttpBinding.ReaderQuotas = new XmlDictionaryReaderQuotas(); //ReaderQuotas, setting to Max
          wsHttpBinding.ReaderQuotas.MaxArrayLength = wsHttpBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
          wsHttpBinding.ReaderQuotas.MaxStringContentLength = wsHttpBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
          wsHttpBinding.ReaderQuotas.MaxDepth = 2147483647;
    
          //Create the Proxy
          ChannelFactory<T> proxy = new ChannelFactory<T>(wsHttpBinding, endpointAddress);
    
          //Sets the MaxItemsInObjectGraph, so that client can receive large objects
          foreach (var operation in proxy.Endpoint.Contract.Operations) {
              DataContractSerializerOperationBehavior operationBehavior = operation.Behaviors.Find<DataContractSerializerOperationBehavior>();
              //If DataContractSerializerOperationBehavior is not present in the Behavior, then add
              if (operationBehavior == null) {
                  operationBehavior = new DataContractSerializerOperationBehavior(operation);
                  operation.Behaviors.Add(operationBehavior);
              }
              //IMPORTANT: As 'operationBehavior' is a reference, changing anything here will automatically update the value in list, so no need to add this behavior to behaviorlist
              operationBehavior.MaxItemsInObjectGraph = 2147483647;
          }
          return proxy;
     }
    

    On this proxy object you will need to do .CreateChannel() to use it.

    Hope this helps.

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

Sidebar

Related Questions

I have a website that talks to a remote WCF web service. Both use
I have a bunch of remote machines all running the same WCF service over
We have a WCF service (BasicHttpBinding) which will always fail after 30 seconds. Calls
I have WCF service which launches the remote process from Process.Start successfully on stand
I have a WCF service running inside a windows service on a remote machine.
I have a netTcp WCF service running in a windows service on a remote
i have the WCF web service within my solution. service has interface which implemeted
System Description: I have a WCF service (self hosted in a windows service) which
I have a WCF service hosted on a remote machine. On my local machine
I have a WCF service configured to use custom UserName validation via the overridden

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.