azure - 无法从 Azure 中的移动服务访问 WCF 服务

标签 azure azure-mobile-services servicebus azureservicebus azure-servicebusrelay


我想从 Windows Azure 中的 Mobile Service 访问 WCF 服务。为此,我使用 Service Bus Relay 连接,该连接配置了凭据来调用 WCF 服务

当我在本地计算机上发布此移动服务时,我可以毫无问题地调用WCF服务

但是当我在 Azure 上发布此移动服务时,在尝试访问它时出现以下错误。 IService1 是 WCF 服务的契约(Contract)。我使用此契约(Contract)在移动服务的 Web.Config 文件中定义了端点。

你能帮我解决这个问题吗?

Exception=System.InvalidOperationException: Could not find default endpoint element that references contract 'ServiceReference1.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

编辑: 经过进一步调查这个问题,我发现,当我们将其托管在云中时,通过添加服务引用生成的代理类并没有获取 Web.config 中定义的端点定义。但是,当该服务在我的计算机的 azure 模拟器上运行时,它会从 Web.config 获取端点定义。

因此,为了解决该问题,我必须以编程方式定义端点并使用 ChannelFactory 类来调用 WCF 服务。

对于为什么移动服务无法读取云中的 Web.config 有什么想法吗?

最佳答案

You can set the app settings as key/value pairs in the appSettings section of the .NET backend project’s Web.config file. These values are used when testing a .NET backend project on the local computer. When running in Azure, these values are ignored and the portal settings are used instead.

http://msdn.microsoft.com/en-us/library/azure/dn529070.aspx

所以我猜移动服务中的 .config 文件有一些特别之处,但我不知道更多。以编程方式初始化 WCF 是一个很好的解决方案。

关于azure - 无法从 Azure 中的移动服务访问 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27164017/

相关文章:

powershell - 如何在 Azure VM 上对 Azure Powershell 进行身份验证

azure-mobile-services - VS 2015 "Add Connected Service"-> "Mobile Services"- 配置按钮已禁用

c# - 如何重构此 C# 代码

c# - 服务总线根据内容过滤消息

azure - 宇宙数据库 : save object type as a property in document

azure - Connect-AzAccount Powershell 本地部署

azure - 无法使用 Web 平台安装程序安装 Service Bus 1.1

amazon-web-services - AWS Lambda 达到大小限制

azure - 从 Github 部署到 Azure 时指定应用程序根目录

Azure存储-下载文件并放入存储中