是否可以将 netTcpBinding 与 VS 2008 开发服务器一起使用?

发布于 2024-07-30 11:19:59 字数 717 浏览 11 评论 0原文

是否可以有这样的 WCF 服务配置:

  <service behaviorConfiguration="WcfService1.Service1Behavior"
    name="WcfService1.Service1">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
      contract="WcfService1.IService1">
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
      contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost/netTcpService" />
      </baseAddresses>
    </host>
  </service>

并将其托管在 Visual Studio 2008 附带的 ASP.NET 开发服务器上,或者我是否必须在 IIS 7 中托管该服务或在托管中自行托管该服务应用程序/Windows 服务?

感谢您的见解!

Is it possible to have a WCF service configuration like this:

  <service behaviorConfiguration="WcfService1.Service1Behavior"
    name="WcfService1.Service1">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
      contract="WcfService1.IService1">
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
      contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost/netTcpService" />
      </baseAddresses>
    </host>
  </service>

And have it hosted on the ASP.NET development server that comes with Visual Studio 2008, or do I necessarily have to host the service in IIS 7 or self-host it in a managed application/Windows service?

Thank you for your insights!

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

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

发布评论

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

评论(1

望她远 2024-08-06 11:20:00

IIS6和内置的Cassini Web服务器都仅支持http,抱歉。

您必须在控制台应用程序等中自行托管您的服务,或者将其托管在 IIS7 中才能使用 NetTCP。

VS2008 SP1 还附带了一个可用于这些目的的 WCF 测试主机应用程序,并且它还支持 NetTCP 和所有其他协议。

它名为 WcfSvcHost.exe,应位于 C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE 目录中。 您可以指定一个包含服务实现及其配置文件的 DLL,它将加载您的服务并为您托管它。

WcfSvcHost 的 MSDN 文档位于:
http://msdn.microsoft.com/en-us/library/bb552363。 aspx

这是它在您的环境中的外观:

替代文本

这是连接到该托管服务的 WcfTestClient.exe - 请注意 netTcp 端点:

替代文字

要在 Visual Studio 中进行设置,请使用 WCF 服务库项目的“属性”选项卡,然后选择将 WcfSvcHost.exe 作为外部程序启动,并提供正确的命令行参数,如下所示:

替代文字< /a>

现在,如果您按 F5 运行包含 WCF 服务的类库,它将启动测试主机并在其中托管您的服务库,准备进行测试。

马克

IIS6 and the built-in Cassini web server both support only http, sorry.

You'll have to either self-host your service in e.g. a console app, or host it in IIS7 in order to use NetTCP.

VS2008 SP1 also comes with a WCF Test Host app that can be used for those purposes, and it supports NetTCP and all other protocols as well.

It's called WcfSvcHost.exe and should be found in your C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE directory. You can specify a DLL containing your service implementation and a config file for it, and it'll load your service and host it for you.

MSDN documentation for the WcfSvcHost is here:
http://msdn.microsoft.com/en-us/library/bb552363.aspx

Here's what it'll look like in your environment:

alt text

and here's the WcfTestClient.exe connected to that hosted service - note the netTcp endpoint:

alt text

To set it up in Visual Studio, use the WCF service library project's "Properties" tab and pick to launch WcfSvcHost.exe as the external program and supply the correct command-line arguments like this:

alt text

Now if you press F5 to run the class library containing your WCF service, it'll launch the test host and host your service library in there, ready to be tested.

Marc

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