我无法正确发布双工wcf服务

时间:2013-09-17 05:57:11

标签: c# asp.net wcf publish

我试图在服务器上发布我的双工wcf服务但没有成功,我可以在本地IIS上发布它,但是当我将它发布到服务器时,它的地址变为net.tcp://win-rhkt30stjd7/Broadcastor/BroadcasterService.svc。正如您所知,在客户端创建服务引用时,此类地址根本没用。我试图将它作为WCF应用程序项目和服务库项目发布,但两者都给出了相同的结果。可能我的Web.config文件中缺少某些内容,但我不知道它是什么。请帮帮我。以下是我的Web.config文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration> 
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="false" />
    <customErrors mode="Off"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="BroadcastorServiceApp.BroadcastorService">
        <endpoint binding="netTcpBinding" contract="BroadcastorServiceApp.IBroadcastorService">
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding>
          <security mode="None"></security>
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <directoryBrowse enabled="true" />
  </system.webServer> 
</configuration>

1 个答案:

答案 0 :(得分:0)

我在address

中看不到任何NET TCP endpoint部分

1:添加基地址如下:

<host>
       <baseAddresses>
           <add baseAddress="net.tcp://localhost:8088" />
       </baseAddresses>
    </host>

2:将地址参数添加到net tcp端点:

<endpoint address = "tcpEndPoint"
          binding="netTcpBinding" 
          contract="BroadcastorServiceApp.IBroadcastorService"></endpoint>

3:Alse将行为名称命名为:

<serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
</serviceBehaviors>

并将其添加到服务中:

<service name="BroadcastorServiceApp.BroadcastorService" behaviorConfiguration="ServiceBehavior">
    <endpoint binding="netTcpBinding" contract="BroadcastorServiceApp.IBroadcastorService"></endpoint>
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>