2012-03-21 14 views
1

Exploring the WCF Named Pipe Binding - Part 1(パート2と3を含む)のような多くの検索や記事を読んでいますが、私はサービスを適切に行うことができませんでした。その後、私は名前付きパイプを介して自分のサービスをテストしてみてくださいWCF、PipeExceptionで名前付きパイプを使用していますか?

<system.serviceModel> 
    <client> 
    <endpoint address="net.pipe://localhost/GlobalPositioningService" 
       binding="netNamedPipeBinding" 
       contract="GI.Services.GlobalPositioning.Contracts.IGlobalPositioning" /> 
    </client> 
    <services> 
    <service name="GI.Services.GlobalPositioning.Services.GlobalPositioningService"> 
     <endpoint address="" 
       binding="wsHttpBinding" 
       contract="GI.Services.GlobalPositioning.Contracts.IGlobalPositioning"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
     <endpoint address="net.pipe://localhost/GlobalPositioningService" 
       binding="netNamedPipeBinding" 
       contract="GI.Services.GlobalPositioning.Contracts.IGlobalPositioning" /> 
     <host> 
     <baseAddresses> 
      <add baseAddress="http://localhost:8080/GlobalPositioningService/"/> 
     </baseAddresses> 
     </host> 
    </service> 
    </services> 

:ここ

は私の設定です

[TestFixture] 
public class GlobalPositioningServiceTests { 
    [TestFixtureSetUp] 
    public void SetUpHost() { 
     var channelFactory = new ChannelFactory<IGlobalPositioning>(binding, new EndpointAddress(address)); 
     channelFactory.Open(); 
     service = channelFactory.CreateChannel(); 
    } 

    private const string address = "net.pipe://localhost/GlobalPositioningService"; 
    private static readonly Binding binding = new NetNamedPipeBinding(); 
    private static IGlobalPositioning service; 
} 

そして、私はまたのServiceHostのインスタンスを使用して別の方法を試してみました:

[TestFixtureSetUp] 
    public void SetUpHost() { 
     host = new ServiceHost(typeof(GlobalPositioningService)); 
     host.AddServiceEndpoint(typeof(IGlobalPositioning), binding, address); 
     host.Open(); 
     service = new GlobalPositioningService(); 
    } 

そして私は常にスタックトレースと、このエラーを取得:

エラー2テスト「GI.Services.GlobalPositioning.Services.Tests.GlobalPositioningServiceTests.GetGlobalPositionWorksWithDiacriticsInMunicipalityName( "143、RUE Marcotte、サンタンヌ・ド・ラ・P \ x00E9rade "、46.5736528d、-72.2021346d) 'failed: System.ServiceModel.EndpointNotFoundException:メッセージを受け入れることができるnet.pipe:// localhost/GlobalPositioningServiceでリッスンしているエンドポイントがありませんでした。これは、しばしば不正なアドレスまたはSOAPアクションによって引き起こされます。詳細については、InnerException(存在する場合)を参照してください。 ----> System.IO.PipeException:パイプエンドポイント 'net.pipe:// localhost/GlobalPositioningService'がローカルマシン上に見つかりませんでした。 System.ServiceModel.ChannelsでSystem.ServiceModel.Channels.NamedPipeConnectionPoolRegistry.NamedPipeConnectionPool.GetPoolKey(EndpointAddressアドレス、ウリ経由)でSystem.ServiceModel.Channels.PipeConnectionInitiator.GetPipeName(ウリURI) で :

サーバースタックトレース.CommunicationPool`2.TakeConnection(EndpointAddressアドレス、ウリのTimeSpanタイムアウト、処理鍵&キーを介して)System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpenでSystem.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(のTimeSpanタイムアウト) で(のTimeSpanタイムアウト) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpanタイムアウト) at Sy System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpanタイムアウト) (System.ServiceModel.Channels.CommunicationObject.Open(TimeSpanタイムアウト)) at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce。 System.ServiceModel.ChannelsでSystem.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpanのタイムアウト)でコール(ServiceChannelチャネル、のTimeSpanタイムアウト)System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpanのタイムアウト、CallOnceManagerカスケード)で .ServiceChannel.Call(System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessageメソッド呼び出し、ProxyOperationRuntime操作)) at .ServiceChannel.Call(Stringアクション、ブール代入、ProxyOperationRuntime操作、Object [] ins、オブジェクト[]出力、TimeSpanタイムアウト)システムでSystem.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessageがreqMsg、IMessageがretMsg)で を[0]に再スローSystem.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessageがメッセージ)

例外で。 GI.Services.GlobalPositioningでGI.Services.GlobalPositioning.Contracts.IGlobalPositioning.GetGlobalPosition(文字列mailingAddress) でRuntime.Remoting.Proxies.RealProxy.PrivateInvoke(のMessageData & msgData、のInt32型) 。C:\ Open \ Projects \ Framework \ Src \ GI.Services \ GI.Services.GlobalPositioning.Services.Tests \ GlobalPositioningServiceTests.cs:行27 のServices.Tests.GlobalPositioningServiceTests.GetGlobalPositionWorksWithDiacriticsInMunicipalityName(文字列アドレス、倍精度、倍長整数) --PipeException C:\オープン\プロジェクト\ Frameworkの\ SRC \ GI.Services \ GI.Services.GlobalPositioning.Services.Tests \ GlobalPositioningServiceTests.csあなたの情報については27

を、私が使用しています:

  1. Visual Studio 2010
  2. Windows 7
  3. NUnitの

そして、私のサービスは、WCFサービスライブラリ内に含まれています。

答えて

1

netNamedPipesBindingを使用して、実行中のサービスインスタンスとの統合テストを実行しようとしているようです。これを行うには、サービスのインスタンスを提供するサービスホストと、サービスへの呼び出しに使用するサービスプロキシインスタンスの両方を持つ必要があります。サンプルのTestFixtureSetupメソッドの両方のコードを組み合わせて、サービスホストとサービスプロキシの両方(CreateChannelメソッドの結果)をインスタンス化することができます。これを行う方法の例については、blog postをご覧ください。

+0

リンクされたブログの投稿はかなり面白いですね!私は簡単にそれを読んで、それは私が達成したいとまったく同じように聞こえる。私は試してさらに掘る時間を許し、成功したかどうかを知らせます。一方、この面白いテスト可能なサービスのポストリンクのために+1! =) –

+0

リンクされたソリューションをありがとう、それは動作します! =)内部エラーについてはまだ分かりませんが、それは別の問題です。 = Pおそらく設定など。 –

関連する問題