【问题标题】:Azure App.Config SharedAccessSignature ErrorAzure App.Config SharedAccessSignature 错误
【发布时间】:2015-05-21 08:18:38
【问题描述】:

我正在尝试创建 WCF 服务。这将由 Windows Azure 服务总线进行身份验证。

我的 app.config 如下所示

<tokenProvider>
<sharedAccessSignature keyName="" key=""/>
</tokenProvider>

在 WCF 测试客户端中运行 WCF 时出现以下错误。

System.Configuration.ConfigurationErrorsException: Unrecognized element 'sharedAccessSignature'

谢谢

【问题讨论】:

    标签: wcf azure app-config


    【解决方案1】:

    以下示例说明了如何创建可通过服务总线中继访问的 WCF 服务:

    在 .svc 文件中这样定义服务:

    <%@ ServiceHost Language="C#" Debug="true" Service="ProblemSolver" CodeBehind="ProblemSolver.svc.cs" %>
    

    请注意,ProblemSolver 实现了一个名为 IProblemSolver 的接口,该接口指定了服务契约。

    我的 web.config 文件的相关部分如下所示:

    <configuration>
    ...
    <system.serviceModel>
      <behaviors>
        <endpointBehaviors>
          <behavior name="sharedAccessSignatureClientCredentials">
            <transportClientEndpointBehavior>
              <tokenProvider>
                <sharedAccessSignature keyName="RootManageSharedAccessKey" key="[YourSharedAccessSignature]" />
              </tokenProvider>
            </transportClientEndpointBehavior>
          </behavior>
        </endpointBehaviors>
      </behaviors>
      <bindings>
        <netTcpRelayBinding>
          <binding name="default" />
        </netTcpRelayBinding>
      </bindings>
      <services>
        <service name="ProblemSolver">
          <endpoint address="sb://[YourServiceBusNamespace].servicebus.windows.net/solver" behaviorConfiguration="sharedAccessSignatureClientCredentials"
            binding="netTcpRelayBinding" bindingConfiguration="default"
            name="RelayEndpoint" contract="IProblemSolver" />
        </service>
      </services>
      <extensions>
        ...
      </extensions>
    </system.serviceModel>
    ...
    </configuration>
    

    【讨论】:

    • 我有一个可以托管在 IIS 中的 WCF 服务。您的以下代码用于自托管 WCF,例如控制台应用程序。 Uri 地址 = ServiceBusEnvironment.CreateServiceUri("sb", "[YourServiceBusNamespace]", "solver"); ServiceHost host = new ServiceHost(typeof(ProblemSolver), address);我希望通过 azure 服务总线公开我现有的内部 WCF 服务。
    猜你喜欢
    • 1970-01-01
    • 2022-12-05
    • 2013-04-18
    • 2017-08-07
    • 2010-10-03
    • 2010-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多