I have a versioning issue with a WCF service contract in which one of the many endpoints which are called for the operation is missing one method from the contract.
My question is, how can I make sure the command is available on the client before attempting to call it?
I tried:
foreach (var od in proxy.Endpoint.Contract.Operations)
{
if (od.Name == "MyMethodName")
{
hasMethod = true;
break;
}
}
Unfortunately, this is using the contract from the calling app and does not actually describe the implementations on the endpoint itself. As a result, it returns true e开发者_StackOverflowven though the endpoint has failed to implement the command.
You'll never actually know until you try it. What you have is a proxy of the implemented contract, but what is on the server side could have changed since you created/generated it.
Assuming it's an http/httpws implementation I suppose you could call and check the service reference and download the wsdl file. That will tell you what methods etc are supported. The problem you're going to have is that even though the name of the method maybe the same, you'll also have to check the return type and parameters to really be sure that it's the same method and that you can call it with the proxy you currently have.
Here is a link on versioning in WCF:
http://msdn.microsoft.com/en-us/library/ms731060.aspx
Here is a link on versioning best practices for WCF:
Best practices for versioning your services with WCF?
精彩评论