【问题标题】:Calling WCF service in Azure Functions在 Azure Functions 中调用 WCF 服务
【发布时间】:2018-05-04 23:25:33
【问题描述】:

有谁知道如何配置从 Azure Function 调用的 WCF 服务?

场景:

  • 我有一个 azure 函数项目。
  • 我有一个由控制器和映射器组成的核心项目。
  • 此核心项目已配置连接服务。
  • 我已经配置了在测试项目中工作的端点和绑定。

但是每次我从我得到的函数中调用它:

在 ServiceModel 客户端配置部分中找不到名称为“ABC”和合同“ABC”的端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

服务配置:

  <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="TranslationBridgeWebServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" useDefaultWebProxy="true">
      <security mode="None" />
    </binding>
  </basicHttpBinding>
  <customBinding>
    <binding name="TranslationBridgeWebServiceSoap12" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
      <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12WSAddressingAugust2004" writeEncoding="utf-8">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      </textMessageEncoding>
      <security authenticationMode="UserNameOverTransport" allowInsecureTransport="false" />
      <httpsTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
    </binding>
  </customBinding>
</bindings>
<client>
  <endpoint address="https://abc/TranslationBridgeExternalService.asmx" binding="customBinding" bindingConfiguration="TranslationBridgeWebServiceSoap12" contract="ABC" name="ABC" />
  <endpoint address="https://abc/TranslationBridgeExternalService.asmx" binding="basicHttpBinding" bindingConfiguration="TranslationBridgeWebServiceSoap" contract="ABC" name="ABC" />
</client>

感谢您的帮助。

【问题讨论】:

    标签: c# azure wcf azure-functions


    【解决方案1】:

    Azure Function App 没有web.config 文件(如果手动放置会被忽略)。

    因此,您必须通过在代码中配置 WCF 客户端来创建它。有效地实例化代码中的所有绑定、端点等。对于每个 WCF 类,总是有一个构造函数来实例化具有所有参数的实体,而无需配置文件。

    【讨论】:

    • 会不会和把调用移到依赖项目一样。这个项目有所有的配置,app.config等,依次调用?或者我在这里错过了什么。谢谢。 :)
    • 不,app.config 也不会被接收。配置由 Functions 运行时控制。
    • 好的。谢谢。会试试的。
    • 另一种选择是执行命令式(在 new BasicHttpBinding/CustomBinding 等代码中进行绑定)而不是 config。看上面的绑定,应该不难实现。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-23
    • 1970-01-01
    • 2011-12-28
    相关资源
    最近更新 更多