vs 2022 WCF服务应用程序项目模板不使用NET TCP
我正在尝试将最简单的WCF服务应用程序与net.tcp一起使用,但行之有效。使用VS2022,如果我创建一个新项目并选择WCF服务应用模板,则新项目将使用Web.config文件,service1.svc文件和iservice.svc打开。
Web.config看起来像这样,
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
如果我运行此示例项目,它将加载WCF测试客户端,并显示使用BasichttpBinding运行的服务。完美的。
如果我从&lt;添加binding =“ basichttpsbinding” scheme =“ https” /&gt; < /code>
&lt; add binding =“ wshttpBinding” scheme =“ htttp”,则将绑定在配置文件中的绑定。 /&gt;
并运行该项目,WCF测试客户端显示WSHTTPBINDING。伟大的!现在,如果我从&lt; add binding =“ wshttpbinding”中将绑定在配置文件中更改绑定。 .tcp“ /&gt; < /code>并运行项目,WCF测试客户端显示了使用basichttpbinding运行的服务。配置文件中甚至没有basichttpbinding绑定!!!!到底从哪里得到的?我已经尝试了几天来nettcpbinding上班,无论我做什么,都无济于事。我认为我会尝试最简单的事情,这是从一个新鲜的空白项目开始,并做出最简单的更改,但仍然没有运气。我想念什么。我几乎找不到有关获得这项工作的信息。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您必须了解&lt; 协议图&gt;。该配置在Machine.config文件中显示默认协议映射。
更一般地,HTTP系统提供的绑定(例如WSHTPBINDING和BASICHTPBINDING)配置为打开事物
默认情况下,默认情况下,默认情况下,nettcpbinding绑定了绑定,以便您必须选择加入以获得支持,例如,对于WS-*规格之一。
您需要修改配置文件,您可以看到如何配置
&lt; nettcpbinding&gt;
。如果您在IIS上托管服务,则需要IIS才能启用net.tcp。如果您需要简单的项目,我建议您从WCF的初学者教程开始。
https://learlen.microsoft.com/en-en--en----- US/dotnet/framework/wcf/获得启动的教程
First you have to understand the meaning of <protocolMapping>. The configuration in shows the default protocol mapping in the machine.config file.
More generally, the HTTP system-provided bindings such as wsHttpBinding and basicHttpBinding are configured to turn things on by
default, whereas the netTcpBinding binding turns things off by default so that you have to opt-in to get support, for example, for one of the WS-* specifications.
You need to modify the configuration file, you can see how
<netTcpBinding>
is configured. If you host your service on IIS, you need IIS to have net.tcp enabled.netTcpBinding In WCF Service With IIS Hosting
nettcpbinding
default-nettcpbinding
If you need simple projects to start with, I suggest you start with wcf's beginners tutorial.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/getting-started-tutorial