c# - 从 Azure ServiceConfig 调用 WCF 服务

标签 c# wcf azure azure-configuration

我将 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 端点地址

最佳答案

感谢大家的帮助。

我找到了解决这个问题的方法。

  1. 程序中关联绑定(bind)和服务地址,然后添加 Serviceconfig 的设置
  2. 添加了 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/

相关文章:

c# - 如何从 ASP.NET 注销 siteminder session

c# - 访问/写入 EventLog 时出现问题

c# - 如何使用 wcf 反序列化不同的接口(interface)实现

c# - Ninject WCF Bootstrap 注册多个服务

azure - 如何使用 ARM 部署具有托管 SSL 证书的应用服务

c# - 如何连接异步枚举?

c# - 没有 assemblyinfo 的通用类型的全名?

c# - 带有命名管道的 WCF 错误 "no endpoint listening"

sql-server - 从 Azure 流分析将数据插入 Azure SQL 数据库表时出现“OutputDataConversionError.TypeConversionError”

azure - Microsoft Graph 可以访问 Azure 资源吗?