将 IIS 部署的 WCF 服务与 Azure 服务总线连接起来

Connecting IIS deployed WCF service with Azure service bus

我正在尝试将本地 WCF 服务与 azure 服务总线连接,现在我已经阅读了文档,他们有仅适用于 sf 托管 wcf 服务的示例,但当该服务托管在 IIS 服务器和所有您时则没有have 是您可以从中使用服务的 url。我已经为预加载设置了我的 IIS 服务器,并且始终 运行 为真,但我不知道如何连接该服务。 所以我想问问你们中是否有人已经这样做来为我指明正确的方向,或者至少为我指出一些可行的文档,我可以从中学习如何做到这一点。

谢谢。

好吧,我知道这是怎么回事,回答了我自己的问题,但昨天当我问这个问题时,我差点把我的笔记本电脑扔出 window:)。

令人恼火的是,Microsoft 和 azure 社区提供的教程只解决了当您在控制台应用程序中托管 wcf 服务时的问题,而不是 IIS,IIS 在原则上应该是相同的,但由于某种原因不是。因此,这是用于连接部署在公司 IIS 上的本地 wcf 服务的 Web 配置部分,在公司网络外部不可见。

<behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="ServiceBusBehavior">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <!--Endpoint=sb://bus-weather.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=e/JdrCvjy/l8nuYYCHXdfssfsfsfsfsfsfsM=-->
              <sharedAccessSignature keyName="RootManageSharedAccessKey" key="e/JdrCvjy/l8nuYYCHXdfssfsfsfsfsfsfsM=" />
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <services>
      <service name="connectServiceBus.GetWeather">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="DefaultBinding" contract="connectServiceBus.IGetWeather"/>
        <endpoint address="sb://bus-weather.servicebus.windows.net/weatherSRV" binding="netTcpRelayBinding" behaviorConfiguration="ServiceBusBehavior" contract="connectServiceBus.IGetWeather"/>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="DefaultBinding" />
      </basicHttpBinding>
      <netTcpRelayBinding>
        <binding name="ServiceBusBinding" />
      </netTcpRelayBinding>
    </bindings>

只需在您的 wcf 服务的 web 配置的 <system.serviceModel> 标记中添加上面的代码片段即可完成,请注意您必须安装服务总线 NuGet 包。
测试客户端可以是示例中的简单控制台应用程序。 对于像我这样的 azure 初学者,如果标签亮起蓝色表示不存在,请不要担心它会起作用。保持冷静和发展:)