2012-04-26 88 views
2

这是从this question后面我已经配置了运行在IIS(从Visual Studio 2010内)运行一个Web服务和一个net.tcp服务的WCF服务。经过很多黑客攻击之后,我设法让Web服务加载到WCF测试客户端,但我无法获得Net.Tcp服务加载到测试客户端。我的WCF元数据配置有什么问题?

这里是我的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测试应用程序访问网络服务的服务:

http://localhost:8523/MyWebService.svc

但如果我输入以下URL WCF测试应用程序我得到一个错误:

net.tcp://localhost:8523/ServerService.svc

以下是错误我看到:

Error: Cannot obtain Metadata from net.tcp://localhost:8523/ServerService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: net.tcp://localhost:8523/ServerService.svc Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:8523/ServerService.svc'. You have tried to create a channel to a service that does not support .Net Framing. It is possible that you are encountering an HTTP endpoint. Expected record type 'PreambleAck', found '72'.

看了this question是有可能,在VS 2010中的Web服务器不支持net.tcp绑定?

+0

我认为这个问题可能是内置于Visual Studio 2010中的Web服务器不支持Net.Tct绑定我正在安装IIS,我将告诉它使用它。 – 2012-04-26 10:18:30

回答

0

它看起来像我看到的问题是,Visual Studio 2010中的Web服务器不支持Net.Tcp绑定。

我已经通过安装IIS7(IIS6不支持Net.Tcp)稍微进一步,并告诉Visual Studio使用IIS来代替。

您可以通过转到服务的属性页并选择“Web选项卡”选择使用本地IIS Web服务器单选按钮并配置Web服务器。

你也可以告诉在这个选项卡上启动一个外部程序,使它启动WcfTestClient.exe并将URL作为命令行参数传递给你的服务。

我仍然有问题,但他们是不同的问题,所以我会打开另一个问题。