WCF 帮助,如何通过 http 公开一个服务,通过 net.tcp 调用另一个服务?
我有一个托管在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要一个路由服务 - 一个向世界公开 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: