Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF what should be the endpointConfigurationName?

Tags:

I have the following config for my WCF service:

<system.serviceModel> <services>   <service behaviorConfiguration="After.BehaviourConfig" name="ServiceInstancingDemo.Service1">     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="After.BindingConfig"       name="After.ConfigName" contract="ServiceInstancingDemo.IService1">       <identity>         <dns value="localhost" />       </identity>     </endpoint>     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />     <host>       <baseAddresses>         <add baseAddress="http://rb-t510/NGCInstancing/Service1.svc" />       </baseAddresses>     </host>   </service> </services> <bindings>   <wsHttpBinding>     <binding name="After.BindingConfig" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferPoolSize="524288111" maxReceivedMessageSize="524288111" allowCookies="false">       <security mode="None" />     </binding>   </wsHttpBinding> </bindings> <behaviors>   <serviceBehaviors>     <behavior name="After.BehaviourConfig">       <serviceMetadata httpGetEnabled="true" />       <serviceDebug includeExceptionDetailInFaults="true" />       <serviceThrottling maxConcurrentCalls="30" maxConcurrentInstances="2147483647" maxConcurrentSessions="30" />     </behavior>   </serviceBehaviors> </behaviors> 

I am able to call the service with the following client code:

NGC.Service1Client ngc = new NGC.Service1Client();          var taskA = Task<string>.Factory.StartNew(() => ngc.WaitThenReturnString(5));          this.listBox1.Items.Add(taskA.Result); 

The config for the client that calls the service is as follows:

 <system.serviceModel>     <bindings>         <wsHttpBinding>             <binding name="Before" closeTimeout="00:01:00" openTimeout="00:01:00"                 receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferPoolSize="524288111"                 maxReceivedMessageSize="524288111" allowCookies="false" />             <binding name="After" closeTimeout="00:01:00" openTimeout="00:01:00"                 receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferPoolSize="524288111"                 maxReceivedMessageSize="524288111" allowCookies="false">                 <security mode="None" />             </binding>             <binding name="WSHttpBinding_IService1" 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="false" />                 <security mode="None">                     <transport clientCredentialType="Windows" proxyCredentialType="None"                         realm="" />                     <message clientCredentialType="Windows" negotiateServiceCredential="true" />                 </security>             </binding>         </wsHttpBinding>     </bindings>     <client>         <endpoint address="http://rb-t510/NGCInstancing/Service1.svc"             binding="wsHttpBinding" bindingConfiguration="Before" contract="NGCInstance.IService1"             name="Before" />         <endpoint address="http://rb-t510/NGCInstancing/Service1.svc"             binding="wsHttpBinding" bindingConfiguration="After" contract="NGCInstance.IService1"             name="After" />         <endpoint address="http://rb-t510/NGCInstancing/Service1.svc"             binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"             contract="NGC.IService1" name="WSHttpBinding_IService1">             <identity>                 <dns value="localhost" />             </identity>         </endpoint>     </client> </system.serviceModel> 

Problem is, I want to add another endpoint that will execute the same functionality but with a different behavior. To do this, I think I'm going to need to pass a string of the enpointConfigurationName to the constructor in the line=new NGC.Service1Client. I don't know what string I need to pass - I would have expected it to be the endpoint configuration name "After.ConfigName" but I tried this and got the following error message:

Could not find endpoint element with name 'After.ConfigName' and contract 'NGC.IService1' 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 name could be found in the client element.

Can anyone please help?

like image 332
Rob Bowman Avatar asked Oct 15 '11 21:10

Rob Bowman


People also ask

What is endpoint configuration name in WCF?

The endpoint with the name "http" is used as the default endpoint for the service application.

What is the default maxStringContentLength for WCF service?

WCF: maxStringContentLength always set to 8192.

What is endpoint address in WCF?

The endpoint address is represented in the Windows Communication Foundation (WCF) programming model by the EndpointAddress class, which contains an optional Identity property that enables the authentication of the endpoint by other endpoints that exchange messages with it, and a set of optional Headers properties, ...

What is binding configuration in WCF?

WCF achieves this by configuring binding attributes of an endpoint. WCF lets you choose HTTP or TCP transport protocol, encoding, etc. just by tweaking the value of binding attribute for an endpoint. To cater to different transport protocols, WCF lets you select HTTP, TCP and MSMQ binding types.


1 Answers

You would pass the value of the name attribute of the corresponding client endpoint you would like to use. For example if you wanted to use the third endpoint:

new NGC.Service1Client("WSHttpBinding_IService1") 
like image 116
Darin Dimitrov Avatar answered Oct 14 '22 06:10

Darin Dimitrov