【问题标题】:WCF help, how can I expose a service over http, that calls another service over net.tcp?WCF 帮助,如何通过 http 公开服务,通过 net.tcp 调用另一个服务?
【发布时间】:2011-02-26 12:06:30
【问题描述】:

我有一个托管在 IIS 中的 WCF .svc 文件。我想使用 basicHTTP 绑定。该服务的工作实际上是通过 net.tcp 调用另一个服务。在本地一切正常,但是当我部署时,我收到了这个错误。

提供的 URI 方案“http”是 无效的;预期“net.tcp”。范围 名称:通过

这是服务器配置

<client>
  <endpoint address="net.tcp://localhost:9300/InternalInterfaceService"
      binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IInternalInterfaceService"
      contract="IInternalInterfaceService" name="NetTcpBinding_IInternalInterfaceService">
    <identity>
      <servicePrincipalName value="localhost" />
    </identity>
  </endpoint>
</client>
<services>
<service name="MyExternalService">
<endpoint address="" binding="basicHttpBinding" contract="IMyExternalService" />
</service>
</services>

这是 svcutil 生成的配置

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IMyExternalService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://myserver.somesdomain.com/Services/MyExternalService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyExternalService"
            contract="IMyInternalService" name="BasicHttpBinding_IMyExternalService" />
    </client>
</system.serviceModel>

我需要做什么才能正确连接。我不想通过 http 公开 InternalInterfaceService。我在这里做错了什么?任何提示或建议都将受到赞赏。

谢谢,
~ck

【问题讨论】:

    标签: binding wcf wcf-binding wcfserviceclient


    【解决方案1】:

    您需要一个路由服务 - 向世界公开 HTTP 端点,并在内部使用 netTcp。

    基本上,你的外向http服务必须成为客户端依次调用内部的netTcp服务。

    您绝对可以在 .NET 3.5 中通过一些努力做到这一点:

    或者您可以在 .NET 4 / VS 2010 中使用新的 WCF 4 路由服务:

    【讨论】:

    • 这里的大部分问题是配置文件被错误地部署到生产环境中。
    猜你喜欢
    • 1970-01-01
    • 2011-05-16
    • 1970-01-01
    • 2019-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-30
    • 1970-01-01
    相关资源
    最近更新 更多