2

IIS でローカルにホストされている WCF WebService 用に netTcp を構成する際に問題が発生しています。これは、DotNet 4.0 (VS2012) を使用する Windows 7 および IIS 7 であり、ファイアウォールは無効になっています。

netTcp を構成するために、次の手順を実行しました。

  1. IIS で、既定の Web サイトに net.tcp 808:* のサイト バインディングを設定します。
  2. Web サービスの IIS では、有効なプロトコルは "http,net.tcp" (スペースなし) です。
  3. Net.Tcp Listener Adapter と Net.Tcp Port Sharing Services が実行されていることを確認しました (それらもリサイクルされました)。

netstat -ona を実行すると、127.0.0.1:808 のリストが表示されません。

これが私のWeb.configです:

<system.web>
<customErrors mode="Off"></customErrors>
<compilation debug="true" targetFramework="4.0"></compilation>
    <identity impersonate="false" />
</system.web> 
<system.serviceModel>
<diagnostics>
  <messageLogging logMalformedMessages="false" logMessagesAtServiceLevel="false"
    logMessagesAtTransportLevel="false" />
</diagnostics>
<bindings>
  <netTcpBinding>
    <binding name="XxxxxxxCommonServiceBinding"  />
  </netTcpBinding>
</bindings>
<services>
  <service behaviorConfiguration="XxxxxxxCommonService_Behavior" name="CS.WebService.Xxxxxxx.Common.XxxxxxxCommonService">
    <endpoint address="net.tcp://localhost:808/CS.WebService.Xxxxxxx.Common.XxxxxxxCommonService/XxxxxxxCommonService.svc" binding="netTcpBinding"
              bindingConfiguration="XxxxxxxCommonServiceBinding" name="XxxxxxxCommonNetTcpBinding"
              contract="CS.ServiceContracts.Xxxxxxx.Common.IXxxxxxxCommonService" />
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />      
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="XxxxxxxCommonService_Behavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false">      
 </serviceHostingEnvironment>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

App.config は次のとおりです。

<system.serviceModel>
<client>
  <endpoint name="CS.WebService.Xxxxxxx.Common.XxxxxxxCommonService"
            address="net.tcp://localhost/CS.WebService.Xxxxxxx.Common.XxxxxxxCommonService/XxxxxxxCommonService.svc"
            binding="netTcpBinding"
            bindingConfiguration="XxxxxxxCommonNetTcpBinding"
            contract="CS.ServiceContracts.Xxxxxxx.Common.IXxxxxxxCommonService"/>
</client>    
</system.serviceModel>

サービスを呼び出そうとするクライアントのコードは次のとおりです。

var endPoint = new EndpointAddress(
            "net.tcp://127.0.0.1:809/CS.WebService.Xxxxxx.Common.XxxxxxCommonService/XxxxxxCommonService.svc");
var binding = new NetTcpBinding { TransferMode = TransferMode.Streamed, SendTimeout = TimeSpan.MaxValue };
var channel = new ChannelFactory<IXxxxxxCommonService>(binding, endPoint);
var proxy = channel.CreateChannel()
var request = new GetDataRequest();
var response = proxy.GetData(request);

この時点で、次のエラーが発生します。

net.tcp://127.0.0.1:809/CS.WebService.Xxxxxx.Common.XxxxxxCommonService/XxxxxxCommonService.svc に接続できませんでした。接続の試行は、00:00:00 の期間継続しました。TCP エラー コード 10061: ターゲット マシンがアクティブに拒否したため、接続できませんでした 127.0.0.1:809。

コードと WebConfig のポートを 808 に変更すると、次のエラーが発生します。

メッセージを受け入れることができる net.tcp://127.0.0.1/CS.WebService.Xxxxxx.Common.XxxxxxCommonService/XxxxxxCommonService.svc でリッスンしているエンドポイントがありませんでした。これは、多くの場合、アドレスまたは SOAP アクションが正しくないことが原因です。詳細については、InnerException (存在する場合) を参照してください。(内部例外はありませんでした)

したがって、 netstat -ona が 127.0.0.1:808 を表示しないため、何かが適切に構成されていないように思えます。しかし、ここでも Net.Tcp サービスが実行されており、リサイクルされています。IIS も正しくセットアップされていると思います。

4

2 に答える 2

1

クライアントとサーバーの両方で SessionMode.Allowed を変更し、すべてが機能し始めました。私のPCでもメモリの問題が発生していたので、メモリをクリアしてsessionModeを正しくしたら、すべて問題ありませんでした。トレースをオンにすることで、正しい方向に進むことができました。

于 2013-07-24T19:12:08.137 に答える
1

[コントロール パネル] > [プログラムと機能] > [Windows の機能の有効化または無効化] に移動します。後続のダイアログで、エントリに移動しMicrosoft .NET Framework 3.5.1て有効にしWindows Communication Foundation Non-HTTP Activationます。(3.5.1Win7がフレームワークに組み込まれていると書かれていますが4.0、同様に機能します)。

0.0.0.0:808netstat の出力に表示されるはずです。

于 2013-07-24T15:38:24.320 に答える