我将 WCF Servicereference 添加到我的 Web 应用程序,以下条目已创建到我的 web.config 中。
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_INameVerification" 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="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://int. NameVerification.com/Default/NameVerificationService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_INameVerification"
contract="NameVerificationService.INameVerification"
name="WSHttpBinding_INameVerification" />
</client>
现在我计划将我的应用程序托管到Azure云平台。 一旦我在云上托管我的应用程序,我希望能够随时更改我的端点 即,
<endpoint address=”https://int. NameVerification.com/Default/NameVerificationService.svc”
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_INameVerification"
contract="NameVerificationService.INameVerification"
name="WSHttpBinding_INameVerification" />
如何从 SericeConfig 将此调用添加到我的 WCF 服务?ServiceConfig 中的实际条目是什么,以便我的应用程序将从服务配置而不是 web.config 中读取我的 WCF 端点地址
最佳答案
感谢大家的帮助。
我找到了解决这个问题的方法。
- 程序中关联绑定(bind)和服务地址,然后添加 Serviceconfig 的设置
- 添加了 ServiceConfig 条目
<Setting name="myServiceAddressUrl" value="https://int. NameVerification.com/Default/NameVerificationService.svc" />
WSHttpBinding binding = new WSHttpBinding();
binding.Name = "WSHttpBinding_INameServiceVerification";
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
binding.ReliableSession.Enabled = false;
binding.TransactionFlow = false;
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Message.ClientCredentialType =
MessageCredentialType.Windows;
string myServiceAddressUrl =
RoleEnvironmentWrapper.GetConfigurationSettingValue(
"AdderssServiceURL.svc");
EndpointAddress myService = new EndpointAddress(myServiceAddressUrl);
NameVerificationClient verificationClient =
new NameVerificationClient(binding, myService );
关于c# - 从 Azure ServiceConfig 调用 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8610079/