【问题标题】:WCF not accessible in Azure在 Azure 中无法访问 WCF
【发布时间】:2011-01-20 13:57:36
【问题描述】:

我有一个 WCF 服务托管在 Azure 的 webrole 中。

当我在开发结构中测试它时,它可以在我的网页(其他网络角色)上正常工作。

但是当我将它部署到云端时,它似乎并没有运行,尽管 webrole 已经准备好了。

当我使用 Fiddler 对我的 WCF 服务的公共方法之一执行 GET 时,我得到:

[提琴手] 连接到 xxxxxxxxxxxxxx.cloudapp.net 失败。 异常文本:连接尝试 失败是因为关联方做了 一段时间后无法正确响应 时间,或建立连接失败 因为连接的主机未能 回复yyyyyyyyyyyyyy

这是服务配置:

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="GovGuard" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  <WebRole name="GovGuard.Services">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="GuardServiceEndpointBinding" endpointName="GuardServiceEndpoint" />
        </Bindings>
      </Site>
    </Sites>
    <ConfigurationSettings>
      <Setting name="DevelopmentConnectionString" />
      <Setting name="GovGuardStorageConnectionString" />
    </ConfigurationSettings>
    <Endpoints>
      <InputEndpoint name="GuardServiceEndpoint" protocol="http" port="81" />
    </Endpoints>
    <Imports>
      <Import moduleName="Diagnostics" />
    </Imports>
    <LocalResources>
      <LocalStorage name="MyCompany.GovGuard.Services.svclog" sizeInMB="1000" cleanOnRoleRecycle="false" />
    </LocalResources>
  </WebRole>
  <WebRole name="GovGuard.Web">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="GuardWebEndpointBinding" endpointName="GuardWebEndpoint" />
        </Bindings>
      </Site>
    </Sites>
    <ConfigurationSettings>
      <Setting name="GuardServiceUrl" />
      <Setting name="DevelopmentConnectionString" />
      <Setting name="GovGuardStorageConnectionString" />
    </ConfigurationSettings>
    <Endpoints>
      <InputEndpoint name="GuardWebEndpoint" protocol="http" port="80" />
    </Endpoints>
    <Imports>
      <Import moduleName="Diagnostics" />
    </Imports>
    <LocalResources>
      <LocalStorage name="MyCompany.GovGuard.Web.svclog" cleanOnRoleRecycle="false" sizeInMB="1000" />
    </LocalResources>
  </WebRole>
</ServiceDefinition>

(编辑) 在我对问题的调查中,它可能是这样的:我使用 Microsoft.SqlServer.Types 程序集作为 WCF 项目中的文件引用。我使用 copy-local = true 将程序集复制到 bin 文件夹,并将其打包在 .csx 文件中。但是.... Microsoft.SqlServer.Types 还需要 SqlServerSpatial.dll 库(不是程序集)。我创建了一个 postbuild 脚本来将该 dll 复制到 bin 中,但我没有成功....

也许有人可以帮助我如何将 dll(不是程序集)打包到 .csx 文件中......

(编辑) 在这里找到它:http://msdn.microsoft.com/en-us/gg271395

【问题讨论】:

  • 您可能需要共享一些代码...一个常见的错误是将端口设置为 80 以外的值。可能需要检查您的 ServiceDefinition.csdef。

标签: wcf azure


【解决方案1】:

如果您尝试进行自托管服务,WCF 将无法正常运行。

由于 HTTP.sys 注册发生的方式,它在本地计算机名称上进行,并且不允许您进行接受负载平衡名称的通配符注册。您可以选择使用内部端点并尝试从您的网络主机连接辅助角色的 IP。

我最终所做的只是将我的 WCF 服务转换为 MVC 端点,并使我的辅助角色成为一个 Web 应用程序。这不是最优雅的,但它确实有效。

【讨论】:

  • 嗨亚伦。我的解决方案有效。 WCF 在 Azure 中应该不是问题,但要注意使用使用本机库的 CLR 库...在我的情况下,整个 WCF 服务没有运行,因为我没有将本机库作为 Azure 的一部分包含在内包!
  • 太棒了..我的问题可能更深地植根于我与 WCF 的爱/恨关系。
【解决方案2】:

最后是可行的解决方案:我在 32 位 Win7 机器上开发,并将 SqlServerSpatial.dll 从我的机器复制到 WCF 项目(使用复制到输出目录和 BuildAction 内容)。这在云中导致了一个奇怪的错误消息,因为那个库是 32 位的!我用 64 位版本更新了库,现在在云中部署后一切正常!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-24
    • 2012-08-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多