WCF 帮助,如何通过 http 公开一个服务,通过 net.tcp 调用另一个服务?

发布于 2024-09-04 12:34:30 字数 2484 浏览 9 评论 0原文

我有一个托管在 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

I have a WCF .svc file hosted in IIS. I want to use basicHTTP binding. This services job is to actually call another service over net.tcp. Everything works fine locally, but when I deployed, I'm getting this error.

The provided URI scheme 'http' is
invalid; expected 'net.tcp'. Parameter
name: via

Here is the server config

<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>

And here is the config that svcutil generates

<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>

What do I need to do to wire this up correctly. I do not want to expose InternalInterfaceService over http. What am I doing incorrectly here? Any tips or suggestions are certainly appreciated.

Thanks,
~ck

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝海 2024-09-11 12:34:30

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

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

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

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

You need a routing service - one that exposes a HTTP endpoint to the world, and uses netTcp internally.

Basically, your outward facing http service must become a client in turn to call the internal netTcp service.

You can definitely do this in .NET 3.5 with a bit of effort:

or you can use the new WCF 4 Routing Service in .NET 4 / VS 2010:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文