2017-08-19 3 views
0

私はコールバック契約IMyCallbackContractを持つWCFデュプレックスサービスIMyDuplexServiceを実装しました。WCFデュプレックスサービスは、サービスの呼び出し前にクライアントのコールバックチャネルが特定のメソッドを実装しているかどうかを判断できますか?

正常にデプロイされました。クライアントはサービスに加入でき、サービスは問題なくコールバックチャネルを使用してクライアント上のメソッドを呼び出すことができます。

私は以来、コールバックコントラクトに新しいメソッドを追加しました。また、それを正常にデプロイすることもできます。古いクライアントは依然として新しいクライアントと同様にサービスに加入することができます。サービスは、コールバックチャネルを使用する古いクライアントと新しいクライアントの両方で古いメソッドを呼び出すことができます。

この「バージョン管理」ロジックを自分で実装することなく、特定のクライアントが古いクライアントか新しいクライアントかを判断する方法はありますか?例えば

、クライアントはコールバック契約の古いバージョンを使用して実装され、サービスが古いクライアントに新しいメソッドを呼び出そうとし、次の例外がスローされた場合: System.ServiceModel.ActionNotSupportedException occurred HResult=-2146233087 Message=The message with Action 'http://domain/virtual_directory/IMyDuplexService/MyNewMethod' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None). Source=mscorlib StackTrace: Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at MyService.IMyCallbackContract.MyNewMethod()

は、ことは可能ですそれを呼び出す前にクライアントが新しいメソッドをサポートしているかどうかを判断するサービス?

私は、リフレクションを使用しようとしましたが、次は古いクライアントでnullを返しません: clientCallbackChannelInstance.GetType().GetMethod("MyNewMethod")

は、私自身の「バージョン管理」スキームの唯一の方法を実装していますか?

P.S.私は自分自身のバージョン管理体系の構築や実装を手伝う必要はありません。私はちょうど "ホイールを再発明"したくありません。 ;)

ありがとうございます。

答えて

0

try catchブロックで新しいメソッドのメソッド呼び出しをラップするのに十分ですか?捕捉された例外は、あなたが見ている特定のタイプです。 例:

try 
{ 
    clientCallbackChannelInstance.MyNewMethod(); 
} 
catch (System.ServiceModel.ActionNotSupportedException exception) 
{ 
    //new method is not supported if code reaches here 
} 
+0

ありがとうございます。実際には、このメソッドを呼び出す前に*を決定しようとしています。たとえば、サーバーとクライアントと対話するUIがある場合、最も古いユーザーは、1つ以上の古いバージョンのクライアントで操作を実行すると、ボタンを無効にするか、表示されないようにすることです。 –

関連する問題