1

我有一个需要实现回调并托管在 IIS 6.0 上的 wcf 服务。由于 IIS 6.0 不支持 net.tcp 绑定,我决定使用自定义绑定,因为该服务由不同时区的不同客户端访问,并且使用自定义绑定,我可以将允许的时钟偏移时间设置为除默认一个。

这是我的服务器配置文件:

<bindings>
  <customBinding>        
    <binding name="pscNetBinding" openTimeout="00:10:00">          
      <reliableSession acknowledgementInterval="00:00:00.2000000"
  flowControlEnabled="true" inactivityTimeout="23:59:59"
  maxPendingChannels="128" maxRetryCount="8" maxTransferWindowSize="128"
  ordered="true" />
      <compositeDuplex />
      <oneWay maxAcceptedChannels="128" packetRoutable="false">
        <channelPoolSettings idleTimeout="00:10:00"
  leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
      </oneWay>
      <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
  messageVersion="Default" writeEncoding="utf-8">
        <readerQuotas maxDepth="2147483647"
  maxStringContentLength="2147483647" maxArrayLength="2147483647"
  maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </textMessageEncoding>
      <httpTransport manualAddressing="false"
  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
  allowCookies="false" authenticationScheme="Anonymous"
  bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
  keepAliveEnabled="true" maxBufferSize="2147483647"
  proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered"
  unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true"/>
    </binding>
  </customBinding>
</bindings>

<services>
  <service name="SchneiderElectric.PSCNet.Server.Services.PSCNetWCFService" behaviorConfiguration="Behaviors1">
    <host>
      <baseAddresses>
        <add baseAddress ="http://10.155.18.18:2000/PSCNet"/>
      </baseAddresses>
    </host>
    <endpoint address="" binding="customBinding"    bindingConfiguration="pscNetBinding"
                                contract="SchneiderElectric.PSCNet.Server.Contracts.IPSCNetWCFService"/>
  </service>
</services>    
<behaviors>
  <serviceBehaviors>
    <behavior name="Behaviors1">
      <serviceMetadata httpGetEnabled = "true"/>
      <!--<serviceThrottling maxConcurrentCalls="2048" maxConcurrentSessions="2048" maxConcurrentInstances="2048" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />-->
    </behavior>
  </serviceBehaviors>
</behaviors>

客户端配置文件:

  <bindings>
    <customBinding>
      <binding name="pscNetBinding" openTimeout="00:10:00">            
        <reliableSession acknowledgementInterval="00:00:00.2000000"
    flowControlEnabled="true" inactivityTimeout="23:59:59"
    maxPendingChannels="128" maxRetryCount="8" maxTransferWindowSize="128"
    ordered="true" />
        <compositeDuplex />
        <oneWay maxAcceptedChannels="128" packetRoutable="false">
          <channelPoolSettings idleTimeout="00:10:00"
    leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
        </oneWay>
        <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
    messageVersion="Default" writeEncoding="utf-8" >
          <readerQuotas maxDepth="2147483647"
    maxStringContentLength="2147483647" maxArrayLength="2147483647"
    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </textMessageEncoding >
        <httpTransport manualAddressing="false"
    maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
    allowCookies="false" authenticationScheme="Anonymous"
    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    keepAliveEnabled="true" maxBufferSize="2147483647"
    proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered"
    unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />                    
      </binding>
    </customBinding>
  </bindings>
  <client>
    <endpoint address="http://10.155.18.18:2000/PSCNet" binding="customBinding"
        bindingConfiguration="pscNetBinding" contract="PSCNetWCFService.IPSCNetWCFService"
        name="pscNetBinding" />
  </client>

如果我在同一台机器上使用服务器和客户端,一切正常。如果我在不同的机器上运行它们,我会收到以下错误:

无法连接到 http://10.155.18.198:9000/e60ba5b3-f979-4922-b9f8-c820caaa04c2。TCP错误码10060:连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应10.155.18.198:9000。

社区中的任何人都可以在这方面帮助我吗?

4

2 回答 2

1

你能显示你定义customBinding的配置部分吗?也许您只是没有粘贴该部分,但是当您定义自定义绑定时,您必须至少指定编码和传输 - 如下所示:

<bindings>
    <customBinding>
        <binding name="MyCustomTextTcpBinding">
            <textMessageEncoding />
            <tcpTransport />
        </binding>
    </customBinding>
</bindings>

您还可以粘贴您定义“pscNetBinding”绑定配置的部分吗?

于 2009-02-18T04:03:13.323 回答
-1

Windows 服务无疑是一个不错的解决方案,但我认为更好的是自托管,您可以对其进行任何类型的绑定。

于 2009-04-26T20:25:59.740 回答