0

我试图在服务器上发布我的双工 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>
4

1 回答 1

0

我没有看到address你的任何部分NET TCP endpoint

1:添加基地址如下:

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

2:将地址参数添加到您的网络 tcp 端点:

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

3:另外给出一个行为名称:

<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>
于 2013-09-17T06:43:57.780 回答