WCF endpointConfigurationName应该是什么?
我的WCF服务有以下配置:WCF endpointConfigurationName应该是什么?,wcf,Wcf,我的WCF服务有以下配置: <system.serviceModel> <services> <service behaviorConfiguration="After.BehaviourConfig" name="ServiceInstancingDemo.Service1"> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="After.BindingCo
<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>
我可以使用以下客户端代码调用该服务:
NGC.Service1Client ngc = new NGC.Service1Client();
var taskA = Task<string>.Factory.StartNew(() => ngc.WaitThenReturnString(5));
this.listBox1.Items.Add(taskA.Result);
NGC.Service1Client NGC=new NGC.Service1Client();
var taskA=Task.Factory.StartNew(()=>ngc.WaitThenReturnString(5));
this.listBox1.Items.Add(taskA.Result);
调用服务的客户端的配置如下所示:
<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>
问题是,我想添加另一个端点,它将执行相同的功能,但具有不同的行为。为此,我想我需要在=new NGC.Service1Client行中向构造函数传递一个enpointConfigurationName字符串。我不知道需要传递什么字符串-我本来希望它是“After.ConfigName”之后的端点配置名称,但我尝试了此操作并收到以下错误消息:
在ServiceModel客户端配置部分中找不到名为'After.ConfigName'和协定'NGC.IService1'的终结点元素。这可能是因为找不到应用程序的配置文件,或者在客户端元素中找不到与此名称匹配的端点元素
有人可以帮忙吗?您将传递要使用的相应客户端端点的
name
属性的值。例如,如果要使用第三个端点:
new NGC.Service1Client("WSHttpBinding_IService1")