这是this question的后续内容我已经配置了在IIS中运行的WCF服务(在Visual Studio 2010中),以运行一个Web服务和一个net.tcp服务。经过大量的黑客攻击后,我设法将Web服务加载到WCF测试客户端,但是我无法将Net.Tcp服务加载到测试客户端。
这是我的Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="ServerService" behaviorConfiguration="ServerServiceBehaviour">
<endpoint address="ServerService.svc"
binding="netTcpBinding"
bindingConfiguration="DefaultNetTcpBindingConfig"
name="NetTcpEndPoint"
contract="IServerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
bindingConfiguration="mexTcpBinding"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/"/>
</baseAddresses>
</host>
</service>
<service name="MyWebService" behaviorConfiguration="WebServiceBehaviour">
<endpoint address="MyWebService.svc"
binding="wsHttpBinding"
bindingConfiguration="DefaultWSBinding"
name="MyWSEndPoint"
contract="IMyWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
bindingConfiguration="mexHttpBinding"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8523/"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="DefaultNetTcpBindingConfig"
maxConnections="5"
portSharingEnabled="true" >
</binding>
<!--<binding name="mexBinding"
portSharingEnabled="true">
<security mode="None"></security>
</binding>-->
</netTcpBinding>
<wsHttpBinding>
<binding name="DefaultWSBinding"/>
</wsHttpBinding>
<mexTcpBinding>
<binding name="mexTcpBinding"/>
</mexTcpBinding>
<mexHttpBinding>
<binding name="mexHttpBinding"/>
</mexHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServerServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
<behavior name="MexBehaviour">
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
</behavior>
<behavior name="WebServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
当我运行Visual Studio调试器以发布服务时,我可以通过在WCF测试应用程序中输入以下URL来访问Web服务:
但是如果我将以下Url输入WCF测试应用程序,我会收到错误:
的net.tcp://本地主机:8523 / ServerService.svc
以下是我看到的错误:
错误:无法从中获取元数据 net.tcp:// localhost:8523 / ServerService.svc如果这是一个Windows(R) 请访问您的Communication Foundation服务 检查您是否已在指定的位置启用元数据发布 地址。有关启用元数据发布的帮助,请参阅 MSDN文档在 http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata交流 错误URI:net.tcp:// localhost:8523 / ServerService.svc元数据 包含无法解析的引用: '的net.tcp://本地主机:8523 / ServerService.svc'。你试过 为不支持.Net Framing的服务创建一个频道。它 您可能遇到HTTP端点。预期 记录类型'PreambleAck',找到'72'。
阅读this question后,VS 2010中的网络服务器可能不支持net.tcp绑定吗?
答案 0 :(得分:0)
我看到的问题是Visual Studio 2010中的Web服务器不支持Net.Tcp绑定。
我通过安装IIS7(IIS6也不支持Net.Tcp)并告诉visual studio使用IIS来进一步改进。
您可以通过转到服务的属性页并选择“Web选项卡”选择“使用本地IIS Web服务器”单选按钮并配置Web服务器来执行此操作。
您还可以告诉我在此选项卡上启动外部程序,使其启动WcfTestClient.exe并将URL作为命令行参数传递给您的服务。
我仍然遇到问题,但问题不同,所以我会打开另一个问题。